1const CompressionPlugin = require('compression-webpack-plugin'); 2 3module.exports = { 4 css: { 5 loaderOptions: { 6 sass: { 7 prependData: () => { 8 const envName = process.env.VUE_APP_ENV_NAME; 9 const hasCustomStyles = 10 process.env.CUSTOM_STYLES === 'true' ? true : false; 11 if (hasCustomStyles && envName !== undefined) { 12 // If there is an env name defined, import Sass 13 // overrides. 14 // It is important that these imports stay in this 15 // order to make sure enviroment overrides 16 // take precedence over the default BMC styles 17 return ` 18 @import "@/assets/styles/bmc/helpers"; 19 @import "@/env/assets/styles/_${envName}"; 20 @import "@/assets/styles/bootstrap/_helpers"; 21 `; 22 } else { 23 // Include helper imports so single file components 24 // do not need to include helper imports 25 26 // BMC Helpers must be imported before Bootstrap helpers to 27 // take advantage of Bootstrap's use of the Sass !default 28 // statement. Moving this helper after results in Bootstrap 29 // variables taking precedence over BMC's 30 return ` 31 @import "@/assets/styles/bmc/helpers"; 32 @import "@/assets/styles/bootstrap/_helpers"; 33 `; 34 } 35 }, 36 }, 37 }, 38 }, 39 devServer: { 40 https: true, 41 proxy: { 42 '/': { 43 target: process.env.BASE_URL, 44 headers: { 45 Connection: 'keep-alive', 46 }, 47 onProxyRes: (proxyRes) => { 48 // This header is ignored in the browser so removing 49 // it so we don't see warnings in the browser console 50 delete proxyRes.headers['strict-transport-security']; 51 }, 52 }, 53 }, 54 port: 8000, 55 }, 56 productionSourceMap: false, 57 chainWebpack: (config) => { 58 config.module 59 .rule('vue') 60 .use('vue-svg-inline-loader') 61 .loader('vue-svg-inline-loader'); 62 }, 63 configureWebpack: (config) => { 64 const crypto = require('crypto'); 65 const crypto_orig_createHash = crypto.createHash; 66 crypto.createHash = (algorithm) => 67 crypto_orig_createHash(algorithm == 'md4' ? 'sha256' : algorithm); 68 69 const envName = process.env.VUE_APP_ENV_NAME; 70 const hasCustomStore = process.env.CUSTOM_STORE === 'true' ? true : false; 71 const hasCustomRouter = process.env.CUSTOM_ROUTER === 'true' ? true : false; 72 const hasCustomAppNav = 73 process.env.CUSTOM_APP_NAV === 'true' ? true : false; 74 75 if (envName !== undefined) { 76 if (hasCustomStore) { 77 // If env has custom store, resolve all store modules. Currently found 78 // in src/router/index.js src/store/api.js and src/main.js 79 config.resolve.alias['./store$'] = `@/env/store/${envName}.js`; 80 config.resolve.alias['../store$'] = `@/env/store/${envName}.js`; 81 } 82 if (hasCustomRouter) { 83 // If env has custom router, resolve routes in src/router/index.js 84 config.resolve.alias['./routes$'] = `@/env/router/${envName}.js`; 85 } 86 if (hasCustomAppNav) { 87 // If env has custom AppNavigation, resolve AppNavigationMixin module in src/components/AppNavigation/AppNavigation.vue 88 config.resolve.alias['./AppNavigationMixin$'] = 89 `@/env/components/AppNavigation/${envName}.js`; 90 } 91 } 92 93 if (process.env.NODE_ENV === 'production') { 94 config.plugins.push( 95 new CompressionPlugin({ 96 deleteOriginalAssets: true, 97 }), 98 ); 99 } 100 }, 101 pluginOptions: { 102 i18n: { 103 localeDir: 'locales', 104 enableInSFC: true, 105 }, 106 }, 107}; 108