Add env variable check to improve build customizations

Added flags for styles, router, and store. If these flags are set
to true, then webpack will attempt to resolve the environment
specific files. If these flags are not explicitly set to true, the
default files are used.

This will give us more flexibility and remove the need to create
empty env files (eg env/router/ibm.js).

Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: I552ad402621a3bbad3e871076a894ecadf9e82c7
diff --git a/vue.config.js b/vue.config.js
index 8176362..1e17def 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -6,7 +6,9 @@
       sass: {
         prependData: () => {
           const envName = process.env.VUE_APP_ENV_NAME;
-          if (envName !== undefined) {
+          const hasCustomStyles =
+            process.env.CUSTOM_STYLES === 'true' ? true : false;
+          if (hasCustomStyles && envName !== undefined) {
             // If there is an env name defined, import Sass
             // overrides.
             // It is important that these imports stay in this
@@ -14,7 +16,7 @@
             // take precedence over the default BMC styles
             return `
               @import "@/assets/styles/bmc/helpers";
-              @import "@/env/assets/styles/_${process.env.VUE_APP_ENV_NAME}";
+              @import "@/env/assets/styles/_${envName}";
               @import "@/assets/styles/bootstrap/_helpers";
             `;
           } else {
@@ -51,6 +53,8 @@
   productionSourceMap: false,
   configureWebpack: config => {
     const envName = process.env.VUE_APP_ENV_NAME;
+    const hasCustomStore = process.env.CUSTOM_STORE === 'true' ? true : false;
+    const hasCustomRouter = process.env.CUSTOM_ROUTER === 'true' ? true : false;
 
     if (process.env.NODE_ENV === 'production') {
       config.plugins.push(
@@ -59,11 +63,16 @@
         })
       );
     }
+
     if (envName !== undefined) {
-      // Resolve store and router modules in src/main.js
-      // depending on environment (VUE_APP_ENV_NAME) variable
-      config.resolve.alias['./store$'] = `./env/store/${envName}.js`;
-      config.resolve.alias['./router$'] = `./env/router/${envName}.js`;
+      if (hasCustomStore) {
+        // If env has custom store, resolve store module in src/main.js
+        config.resolve.alias['./store$'] = `./env/store/${envName}.js`;
+      }
+      if (hasCustomRouter) {
+        // If env has custom router, resolve router module in src/main.js
+        config.resolve.alias['./router$'] = `./env/router/${envName}.js`;
+      }
     }
   },
   chainWebpack: config => {