To this point we have been relying on Ember CLI and only working with our applications in development. But, what do you do when you are ready to deploy your application? Ember CLI is not built for production, it is only for use in development. But, Ember CLI does give us a command to build our ember app for both production and development.
To create a development build of our app type:
ember build. This will store your files in the
dist directory in your project's root folder.
We do have a few options that we can pass in to customize our build and process. First, we can pass the
--watch flag. This keeps the build process running so your assets are rebuilt as you make changes to your app.
The most common option that you will end up passing the build command to specify your environment. To build for production you can type
ember build --environment="production" or
ember build -prod. The production assets that are built for you are minified and fingerprinted. They are also stored in the
To customize where your build output is stored you can use the
-o flag. For example, if you have an EmberCLI app that lives in the root of a Rails app (you probably shouldn't do that) you could customize your build output so that it will be placed in your Rails assets by typing:
We will spend some time discussing a few deploy strategies for your Ember app at a later time, but now you have a deployable build. At the most basic level, you could drop the contents of the
dist directory into a publicly accessible location like an s3 bucket and your app will work. Of course in the case of our School Directory app, we would need to have a backend available as our "backend" was in Ember CLI Mirage which is only available in development and testing.
That's it for now, for more on Ember CLI commands, take a look at the Ember CLI User Guide.