【问题标题】:How to organize an Ember CLI project with Node + Express app?如何使用 Node + Express 应用程序组织 Ember CLI 项目?
【发布时间】:2014-08-22 20:48:35
【问题描述】:

我是前端 + PHP 开发人员,不熟悉 Node + Express 和 Ember JS。我习惯了像 CodeIgniter 这样的 MVC 框架。我非常了解 CodeIgniter 的文件夹结构(将我的视图、CSS、控制器等放在哪里),但我很难理解如何组织我的 Node + Express + Ember 应用程序。我想了解如何构建应用程序。

我只是将使用 Ember CLI 创建的应用程序转储到我的 Node + Express 应用程序的公共文件夹中。这是正确的方法吗?此外,这似乎会导致 Ember Build 出现错误。

Nagarjuns-MacBook-Pro:public nagarjun$ ember build
version: 0.0.40
Building
app/app.js: line 1, col 1, 'import' is only available in ES6 (use esnext option).
app/app.js: line 2, col 1, 'import' is only available in ES6 (use esnext option).
app/app.js: line 3, col 1, 'import' is only available in ES6 (use esnext option).
app/app.js: line 14, col 1, 'export' is only available in ES6 (use esnext option).

4 errors

app/router.js: line 1, col 1, 'import' is only available in ES6 (use esnext option).
app/router.js: line 11, col 1, 'export' is only available in ES6 (use esnext option).

2 errors

app/routes/sign-in.js: line 1, col 1, 'import' is only available in ES6 (use esnext option).
app/routes/sign-in.js: line 3, col 1, 'export' is only available in ES6 (use esnext option).

2 errors

===== 3 JSHint Errors

Built project successfully. Stored in "dist/".

当我在运行node bin/www 后加载我的项目时,我仍然只能看到 Express 默认布局。考虑到 Express 在其自己的 Views 文件夹中使用 Jade 模板,我对如何组织我的项目有很多困惑。我只是忽略那个文件夹吗?

【问题讨论】:

    标签: node.js ember.js express


    【解决方案1】:

    我个人建议采取稍微不同的方法:在开发过程中,将您的 ember 应用程序更像一个 3rd 方客户端并在单独的文件夹结构中开发它,这样您就可以获得 ember-cli 的所有好处,而您却没有t 混合两个 MVC 文件夹结构,在我看来这很快就会变得混乱。

    因此,您将拥有一个 server 文件夹和一个单独的 client 文件夹,然后您可以代理您的 ember 应用程序,或者将您自己的 API 视为第 3 方 API。对于生产,您只需构建整个 Ember 应用程序并让您的 API 服务器为应用程序提供服务。

    我还推荐http://sailsjs.org/,而不是直接 express,它建立在 express 之上,并提供更好的文件夹结构,与 ember 有点可比,并且还有自己的 cli。

    这是我们公司在生产中使用的,我还在sails和ember-cli之上创建了一个cli,我们在内部使用:https://github.com/artificialio/sane 这可能会更好地解释文件夹结构和所有内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-09
      • 1970-01-01
      • 1970-01-01
      • 2020-04-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多