23

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!

Drew Baker
  • 14,154
  • 15
  • 58
  • 97

2 Answers2

34

All you need to do 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'
}
Caltor
  • 2,538
  • 1
  • 27
  • 55
dougajmcdonald
  • 19,231
  • 12
  • 56
  • 89
  • I wish it were `ember build production` – sheriffderek Nov 30 '16 at 16:49
  • 3
    You can also use `ember build -prod` as `-prod` is aliased by ember-cli to `--environment=production`. Not quite as elegant as `ember build production`, but a bit shorter. – Simon Dec 16 '16 at 09:21
-4

For anyone looking, you would add this to your Brocfile.js (found in the App root)

// When in Production mode, minify code
if (app.env === 'production') {
    minifyCSS: {
        enabled: true
    }
    minifyJS: {
        enabled: true
    }
}

Then run this command in Terminal (make sure you are in your App directory):

ember build --environment=production
Drew Baker
  • 14,154
  • 15
  • 58
  • 97
  • 6
    The minification should be done by `ember-cli` automatically when you build with production environment. – Justin Lau Jun 19 '15 at 06:24
  • 3
    Agreed. This code is unnecessary (redundant). Running the command is all you need to minify the CSS and JS. Unless you've made modifications to the default configuration, this IS the default configuration. – Brian Genisio Aug 20 '15 at 17:37
  • 1
    That first code block is also not syntactically correct javascript. You're mixing a statement with what looks like a partial object literal. – Kit Sunde Oct 16 '16 at 13:41