Create separate file for Vue Router routes
Separating routes into its own JS file to allow for easier env
customizations.
Update store resolve path to make sure right env stores modules
are imported in every file.
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: I5c646c81fab54085198b2e179be80c954258f51c
diff --git a/vue.config.js b/vue.config.js
index 53dc614..ca8e9f0 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -58,22 +58,16 @@
const hasCustomAppNav =
process.env.CUSTOM_APP_NAV === 'true' ? true : false;
- if (process.env.NODE_ENV === 'production') {
- config.plugins.push(
- new CompressionPlugin({
- deleteOriginalAssets: true
- })
- );
- }
-
if (envName !== undefined) {
if (hasCustomStore) {
- // If env has custom store, resolve store module in src/main.js
- config.resolve.alias['./store$'] = `./env/store/${envName}.js`;
+ // If env has custom store, resolve all store modules. Currently found
+ // in src/router/index.js src/store/api.js and src/main.js
+ config.resolve.alias['./store$'] = `@/env/store/${envName}.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`;
+ // If env has custom router, resolve routes in src/router/index.js
+ config.resolve.alias['./routes$'] = `@/env/router/${envName}.js`;
}
if (hasCustomAppNav) {
// If env has custom AppNavigation, resolve AppNavigationMixin module in src/components/AppNavigation/AppNavigation.vue
@@ -82,6 +76,14 @@
] = `@/env/components/AppNavigation/${envName}.js`;
}
}
+
+ if (process.env.NODE_ENV === 'production') {
+ config.plugins.push(
+ new CompressionPlugin({
+ deleteOriginalAssets: true
+ })
+ );
+ }
},
chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {