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