Cover image preview Cover image

Building for production

by Gene — posted on 5 April 2022

The build process will read the default configuration of the web application, from the file ./config/default.json.
This file contains, among the other options, the base url of the application that by default is /:

./config/default.json

{
  "zuix": {
    ...
    ...
    "app": {
      "title": "My web application",
      "baseUrl": "/",
      ...
    }
  }
}

Depending on the hosting service where the application will be published, the base url might not be the root of the website, like it happens for GitHub hosted pages, where the base url is the name of the project, unless custom domain is used:

https://<account_name>.github.io/<project_name>/

For this purpose, when building for production, a different configuration file is used with the proper base url set:

./config/production.json

{
  "zuix": {
    ...
    ...
    "app": {
      "title": "My web application",
      "baseUrl": "/my-web-app/",
      ...
    }
  }
}

also, the {{ app.baseUrl }} variable, if used in a template, will be replaced with the proper value depending on the selected configuration.

So, to select the production configuration when building the web application, the environment variable NODE_ENV must be set to production:

NODE_ENV=production npx zuix build

it's also possible to simulate the production hosting when running the development server:

NODE_ENV=production npx zuix start

in which case, the application will be served at the url specified by baseUrl in the production configuration file.

-~=(Web Starter)=~- Documentation |