Use Forever with Ember-CLI

感情迁移 提交于 2019-12-04 07:27:16

Ember-CLI apps are NOT node apps, they are Browser apps, so you don't need anything special to serve them. To keep and Ember-CLI app running permanently, I suggest doing:

ember build --environment=production

This will perform the necessary build steps so that the code works in browsers (e.g, transpiling ES6 modules) and put the code in the build folder. It will also minify JS files and fingerprint all resources (this only happens when the environment is production).

All you have to to then is put the files inside the dist/ folder on a Web Server.

I suggest Apache or Nginx, but anything will work.

Edit

As Omair Vaiyani pointed out, this might not work in some servers because Ember-CLI uses the locationType: 'auto' which defaults to 'history'. For that to work, you have to configure your SERVER to serve the ember app from all routes.

What I do, and server me well because I don't have control over the server, is to simply change the locationType to 'hash', which will generate URLs with hashes (http://myemberapp/#/myroute/myid) and will work with any server. Just edit the environment.js file accordingly:

module.exports = function(environment) {
   var ENV = {
      /* other stuf ... */
      locationType: 'hash',
      /* other stuf ... */
   },
   /* other stuff */

```

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!