Documentation for building your application

Custom Build

New projects include built-in support for development and production builds of your application, but you can also create custom environments, in case you also need special builds for environments like test, staging, etc.

To illustrate, we'll walk through the steps required to add a new build for a staging environment.

Create Custom Config

The first step is to create a custom config file, and add it to /config/env. In this example we will create a new file named /config/env/staging.js that looks like this:

 * Staging environment settings
 * This file is where you define overrides for any of the config settings that
 * should only be applied in the staging environment.
 * The staging environment is defined as 'process.env.LORE_ENV=staging' and
 * is automatically set when webpack is invoked using the --env.lore=staging argument.

export default {

   * To override a config setting, specify the name of the config file you
   * want to override, followed by the settings you want to change.

  // actions: {
  //   normalize: true
  // },

  // connections: {
  //   default: {
  //     apiRoot: ''
  //   }
  // }


This file allows us to customize the application settings for this environment, such as setting the API location, specific feature flags, whatever we need.

Create Custom Script

Next we need to add a script to package.json so that we can build the project for this environment. For that, we're going to add the script below:

"scripts": {
  "build:staging": "npm run clean && webpack --env.webpack=production --env.lore=staging -p",

This script will tell webpack to build the files in production mode, which sets the NODE_ENV to production, but then tells lore to use the staging config. The -p at the end tells Webpack to minify and uglify the assets.


That's it! Those steps are all you need to set up your own custom build environments, and you can create as many as you want.