blob: 769f5c906bdf717ca72a33aa3e69326bde682685 [file] [log] [blame]
Derick Montaguefded0d12019-12-11 06:16:40 -06001const CompressionPlugin = require('compression-webpack-plugin');
Derick Montaguef3ab8bc2019-12-10 15:13:25 -06002
Yoshie Muranaka74c24f12019-12-03 10:45:46 -08003module.exports = {
Yoshie Muranakad388a282020-07-08 16:15:46 -07004 css: {
5 loaderOptions: {
6 sass: {
7 prependData: () => {
8 const envName = process.env.VUE_APP_ENV_NAME;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -07009 const hasCustomStyles =
10 process.env.CUSTOM_STYLES === 'true' ? true : false;
11 if (hasCustomStyles && envName !== undefined) {
Yoshie Muranakad388a282020-07-08 16:15:46 -070012 // 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";
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070019 @import "@/env/assets/styles/_${envName}";
Yoshie Muranakad388a282020-07-08 16:15:46 -070020 @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 }
Derick Montague602e98a2020-10-21 16:20:00 -050035 },
36 },
37 },
Yoshie Muranakad388a282020-07-08 16:15:46 -070038 },
Yoshie Muranaka74c24f12019-12-03 10:45:46 -080039 devServer: {
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080040 https: true,
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080041 proxy: {
Derick Montaguefded0d12019-12-11 06:16:40 -060042 '/': {
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080043 target: process.env.BASE_URL,
Dixsie Wolmersbf37b312021-10-12 15:07:41 -050044 headers: {
45 Connection: 'keep-alive',
46 },
Derick Montague602e98a2020-10-21 16:20:00 -050047 onProxyRes: (proxyRes) => {
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060048 // This header is ignored in the browser so removing
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080049 // it so we don't see warnings in the browser console
50 delete proxyRes.headers['strict-transport-security'];
Derick Montague602e98a2020-10-21 16:20:00 -050051 },
52 },
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060053 },
Derick Montague602e98a2020-10-21 16:20:00 -050054 port: 8000,
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060055 },
56 productionSourceMap: false,
Ed Tanousf8207742024-04-08 14:27:07 -070057 chainWebpack: (config) => {
58 config.module
59 .rule('vue')
60 .use('vue-svg-inline-loader')
61 .loader('vue-svg-inline-loader');
62 },
Derick Montague602e98a2020-10-21 16:20:00 -050063 configureWebpack: (config) => {
Gunnar Mills99706ff2022-01-14 19:52:33 +000064 const crypto = require('crypto');
65 const crypto_orig_createHash = crypto.createHash;
66 crypto.createHash = (algorithm) =>
67 crypto_orig_createHash(algorithm == 'md4' ? 'sha256' : algorithm);
68
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080069 const envName = process.env.VUE_APP_ENV_NAME;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070070 const hasCustomStore = process.env.CUSTOM_STORE === 'true' ? true : false;
71 const hasCustomRouter = process.env.CUSTOM_ROUTER === 'true' ? true : false;
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070072 const hasCustomAppNav =
73 process.env.CUSTOM_APP_NAV === 'true' ? true : false;
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080074
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080075 if (envName !== undefined) {
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070076 if (hasCustomStore) {
Yoshie Muranaka816d9472020-09-03 11:19:28 -070077 // 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`;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070081 }
82 if (hasCustomRouter) {
Yoshie Muranaka816d9472020-09-03 11:19:28 -070083 // If env has custom router, resolve routes in src/router/index.js
84 config.resolve.alias['./routes$'] = `@/env/router/${envName}.js`;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070085 }
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070086 if (hasCustomAppNav) {
87 // If env has custom AppNavigation, resolve AppNavigationMixin module in src/components/AppNavigation/AppNavigation.vue
Ed Tanous81323992024-02-27 11:26:24 -080088 config.resolve.alias['./AppNavigationMixin$'] =
89 `@/env/components/AppNavigation/${envName}.js`;
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070090 }
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080091 }
Yoshie Muranaka816d9472020-09-03 11:19:28 -070092
93 if (process.env.NODE_ENV === 'production') {
94 config.plugins.push(
95 new CompressionPlugin({
Derick Montague602e98a2020-10-21 16:20:00 -050096 deleteOriginalAssets: true,
Ed Tanous81323992024-02-27 11:26:24 -080097 }),
Yoshie Muranaka816d9472020-09-03 11:19:28 -070098 );
99 }
Derick Montaguef3ab8bc2019-12-10 15:13:25 -0600100 },
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -0600101 pluginOptions: {
102 i18n: {
103 localeDir: 'locales',
Derick Montague602e98a2020-10-21 16:20:00 -0500104 enableInSFC: true,
105 },
106 },
Yoshie Muranaka74c24f12019-12-03 10:45:46 -0800107};