Use Forever with Ember-CLI

人盡茶涼 提交于 2019-12-06 02:38:08

问题


I've set up a website using Ember-CLI and it is now ready for production, so we're looking for a way to keep it running permanently.

Right now we're using $ ember serve --port 80

but obviously this only works whilst we're logged in. I've used Forever before to keep a node app running but am not sure how to make this work with Ember CLI, as the 'ember serve' command obviously does more than just running app.js?

Any input would be appreciated!


回答1:


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 */

```



来源:https://stackoverflow.com/questions/25227756/use-forever-with-ember-cli

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