官术网_书友最值得收藏!

Deployment

After creating your application you'll need to be able to deploy it. Let's take a look at a few ways to deploy your application.

How to do it...

  1. The first fundamental step before deployment is building your project. To build your application, run the build command:
    $ ember build
    
  2. This command builds the contents of the project in the /dist folder. To build your project for production, you'll need to use the -prod argument:
    $ ember build -prod
    
  3. If you need, you can designate the default output folder:
    $ ember build –prod –o<directory>
    

Building your application for production will automatically minify your files as well as fingerprint them. This does not occur when your environment is set up for development, which is set by default.

The /dist folder has everything that your web server needs. At this point, to deploy your application, all you need to do is copy the contents of the /dist folder to your web server.

Tip

Ember CLI Deploy

Another great way to deploy your Ember application is to use the Ember add-on called Ember CLI Deploy. This add-on helps you deploy your Ember application to a number of different services. It has a very active community behind it so you can expect frequent updates. As your Ember applications grows you may want to take a look at this. You can find more information about Ember CLI deploy here: https://github.com/ember-cli/ember-cli-deploy.

Deploying to Firebase

Firebase is a backend service that can handle data storage, user authentication, static hosting, and more. For this example we'll be using Firebase as a way to host our Ember application.

  1. Sign up for an account with Firebase. This can be done at http://www.firebase.com.
  2. Next, install the firebase-tools:
    $ npm install –g firebase-tools
    
  3. After you have a project created and you're ready to deploy, run the firebase init command in the root of the folder:
    $ firebase init
    

    After running this command, you'll be asked a few questions. It will first ask you to sign in to your Firebase account. Enter your credentials to continue. Then, it will ask for the name of your Firebase application. Lastly, it will ask for the name of your app's public directory. In most cases, this should be /dist.

  4. Edit the firebase.json file and add some rewrite rules:
    {
      "firebase": "my-new-app",
      "public": "dist",
      "rewrites": [{
        "source": "**",
        "destination": "/index.html"
      }],
    }

    This is needed to help with navigation in the application. Change my-new-app to the name of your app as well.

  5. All that's left is to deploy to Firebase:
    $ firebase deploy
    

How it works...

The Ember CLI build process is compiled using the Broccoli asset pipeline and the build tool itself. It takes all the files and minifies, fingerprints, and organizes them in the /dist folder so that it is ready to be deployed.

Many services exist that can host static files. You can use Firebase or just host it in your own Nginx or Apache server after building it for production.

主站蜘蛛池模板: 定南县| 祁东县| 富平县| 汶川县| 大方县| 班戈县| 广汉市| 增城市| 上饶市| 沈阳市| 青海省| 遂川县| 高尔夫| 贞丰县| 辽阳县| 革吉县| 商都县| 富源县| 嵊州市| 蓬溪县| 军事| 云安县| 平潭县| 望谟县| 双江| 乌拉特后旗| 安龙县| 吉木萨尔县| 桂平市| 巴塘县| 五家渠市| 大石桥市| 盐山县| 江都市| 苍山县| 赤壁市| 舞钢市| 京山县| 濮阳市| 会昌县| 澎湖县|