# Build Customization
This document provides instructions for how to add environment specific modifications to the Web UI.
# Setup
- Create a
.env.<ENV_NAME>file in the project root - Add
NODE_ENV=productionkey value pair in the file - Add
VUE_APP_ENV_NAMEkey with the value set to the new environment name
Example .env.ibm:
NODE_ENV=production
VUE_APP_ENV_NAME=ibm
# Store
TIP
Vuex store modules (opens new window) contain the application's API calls.
- If making customizations to the default store, add
CUSTOM_STORE=truekey value pair to the new .env file. - Create a
<ENV_NAME>.jsfile insrc/env/storeWARNING
The filename needs to match the
VUE_APP_ENV_NAMEvalue defined in the .env file. The store import insrc/main.jswill resolve to this new file. - Import the base store
- Import environment specific store modules
- Use the Vuex (opens new window)
registerModuleandunregisterModuleinstance methods to add/remove store modules - Add default export
Example src/env/store/ibm.js:
import store from '@/store; //@ aliases to src directory
import HmcStore from './Hmc/HmcStore';
store.registerModule('hmc', HmcStore);
export default store;
# Router
TIP
Vue Router (opens new window) determines which pages are accessible in the UI.
- If making customizations to the default router, add
CUSTOM_ROUTER=truekey value pair to the new .env file. - Create a
<ENV_NAME>.jsfile insrc/env/routerWARNING
The filename needs to match the
VUE_APP_ENV_NAMEvalue defined in the .env file. The routes import insrc/router/index.jswill resolve to this new file. - Define new routes (opens new window).
TIP
Use static imports (over lazy-loading routes) to avoid creating separate JS chunks. Static imports also helps to keep the total build size down.
- Add default export
# App navigation
The Vue Router definition is closely tied to the app navigation but should be configured separately. The Vue Router is responsible for defining the application routes which is not always the same as what is visible in the app navigation. This configuration will make customizations to the rendered markup in src/components/AppNavigation/AppNavigation.vue.
- If making customizations to the app navigation, add
CUSTOM_APP_NAV=truekey value pair to the new .env file. - Create a
<ENV_NAME>.jsfile insrc/env/components/AppNavigationWARNING
The filename needs to match the
VUE_APP_ENV_NAMEvalue defined in the .env file. The AppNavigationMixin import insrc/components/AppNavigation/AppNavigation.vuewill resolve to this new file. - Your custom mixin should follow a very similar structure to the default
AppNavigationMixin.js file. It should include a data property named
navigationItemsthat should be an array of of navigation objects. Each navigation object should have anidandlabelproperty defined. Optionally it can includeicon,route, orchildrenproperties. - Add default export
# Theming
TIP
Bootstrap theming (opens new window) allows for easy visual customizations.
- If making customizations to the default styles, add
CUSTOM_STYLES=truekey value pair to the new .env file. - Create a
_<ENV_NAME>.scsspartial insrc/env/assets/stylesWARNING
The filename needs to match the
VUE_APP_ENV_NAMEvalue defined in the .env file. The webpack sass loader will attempt to import a file with this name. - Add style customizations. Refer to bootstrap documentation (opens new window) for details about color overrides (opens new window) and other customizable options (opens new window).
Example for adding custom colors
src/env/assets/styles/_ibm.scss
// Custom theme colors
$primary: rebeccapurple;
$success: lime;
# Local development
- Add the same
VUE_APP_ENV_NAMEkey value pair to yourenv.development.localfile. - Use serve script
npm run serve
# Production build
Run npm build script with vue-cli --mode option
flag (opens new window). This requires
corresponding .env file to exist.
npm run build -- --mode ibm
OR
pass env variable directly to script
VUE_APP_ENV_NAME=ibm npm run build