如何使用Ember CLI进行生产准备工作? [英] How to make a production ready build using Ember CLI?

查看:111
本文介绍了如何使用Ember CLI进行生产准备工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Ember中构建了一个Web应用程序,并准备将其放在服务器上供公众使用。我只想做/ dist /文件夹,然后我将通过FTP手动上传到服务器。



如何在Ember中为此建立一个dist?我无法弄清楚如何打开分区,并从构建中删除测试文件。



我猜这与我的Brocfile.js有关, bower.json,package.json,environment.js或tester.json文件,但我真的不知道哪一个,或者该配置是什么样子。



奖金:我想知道如何禁用/启用细化,因为我想与同事分享我的制作。



应该更多的只是ember build - 环境生产。需要更改什么文件以启用/禁用最小化,包括测试等?或者是ember build - 环境生产是什么?



谢谢!

解决方案

所有你应该运行创建你的 dist 文件夹是运行:

  ember build --environment = production 

或作为@Simon已经提到

  ember build -prod 

但是要添加一些肉到骨头:



如果您需要更改设置,可以通过查找 environment.js 文件应该在 config 文件夹中。



Ember文档建议更改 locationType:'hash'以确保历史记录与路由器正常工作。



您有一个部分将看起来像这样,您可以在其中添加 ENV.theVariableToSet ='myValue'; 为您想要更改的任何内容

  if(environment ==='production'){ 
ENV.locationType ='hash'
}


I've been building a web app in Ember, and am ready to put it on a server for public use. I just want to make the /dist/ folder, which i will then manually upload to a server via FTP.

How do I build a dist for this in Ember? I can't figure out how to turn on minification and remove the tests files from the build.

I'm guessing it has something to do with my Brocfile.js, bower.json, package.json, environment.js or tester.json files, but I don't really know which one, or what that config would look like.

Bonus: I'd like to know how to turn disable/enable minification too, as I want to share my production build with a colleague to see.

It should be more that just "ember build --environment production". What files do I need to change to enable/disable minfication, to include tests etc? Or is that what "ember build --environment production" does?

Thanks!

解决方案

All you should run to create your dist folder is to run:

ember build --environment=production

or as @Simon has mentioned

ember build -prod

But to add some meat to the bones:

If you need to change settings, you can do this by finding your environment.js file which should be in the config folder.

The Ember documents suggest changing the locationType: 'hash' to ensure the history works ok with the router.

You have a section which will look like this, where you can add ENV.theVariableToSet = 'myValue'; for anything you want to change

if (environment === 'production') {
  ENV.locationType = 'hash'
}

这篇关于如何使用Ember CLI进行生产准备工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆