summaryrefslogtreecommitdiff
path: root/vue.config.js
diff options
context:
space:
mode:
authorYoshie Muranaka <yoshiemuranaka@gmail.com>2020-08-13 00:12:44 +0300
committerYoshie Muranaka <yoshiemuranaka@gmail.com>2020-09-01 20:30:41 +0300
commit044b1bb84225b96c3c1ab47d7b37398b8649cf9f (patch)
tree3d9660a8bf7520227aeaae864a15448d191be861 /vue.config.js
parentf295d1b8d4bf8439b093fae1ea021ee99e04f27f (diff)
downloadwebui-vue-044b1bb84225b96c3c1ab47d7b37398b8649cf9f.tar.xz
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
Diffstat (limited to 'vue.config.js')
-rw-r--r--vue.config.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/vue.config.js b/vue.config.js
index 81763622..1e17def0 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -6,7 +6,9 @@ module.exports = {
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 @@ module.exports = {
// 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 @@ module.exports = {
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 @@ module.exports = {
})
);
}
+
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 => {