blob: e33918e420b811b6339fc8d2c0d85182b4312cd5 [file] [log] [blame]
Derick Montaguefded0d12019-12-11 06:16:40 -06001const CompressionPlugin = require('compression-webpack-plugin');
Ed Tanous740cbd52024-04-20 16:35:34 -07002const webpack = require('webpack');
3const LimitChunkCountPlugin = webpack.optimize.LimitChunkCountPlugin;
Derick Montaguef3ab8bc2019-12-10 15:13:25 -06004
Yoshie Muranaka74c24f12019-12-03 10:45:46 -08005module.exports = {
6 devServer: {
Ed Tanous7d6b44c2024-03-23 14:56:34 -07007 server: {
8 type: 'https',
9 },
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080010 proxy: {
Derick Montaguefded0d12019-12-11 06:16:40 -060011 '/': {
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080012 target: process.env.BASE_URL,
Derick Montague602e98a2020-10-21 16:20:00 -050013 onProxyRes: (proxyRes) => {
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060014 // This header is ignored in the browser so removing
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080015 // it so we don't see warnings in the browser console
16 delete proxyRes.headers['strict-transport-security'];
Derick Montague602e98a2020-10-21 16:20:00 -050017 },
18 },
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060019 },
Derick Montague602e98a2020-10-21 16:20:00 -050020 port: 8000,
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060021 },
22 productionSourceMap: false,
Ed Tanousf8207742024-04-08 14:27:07 -070023 chainWebpack: (config) => {
Ed Tanous7d6b44c2024-03-23 14:56:34 -070024 config.resolve.alias.set('vue', '@vue/compat');
25 config.module
26 .rule('vue')
27 .use('vue-loader')
28 .tap((options) => {
29 options['compilerOptions'] = { compatConfig: { MODE: 2 } };
30 return options;
31 });
Ed Tanousf8207742024-04-08 14:27:07 -070032 config.module
33 .rule('vue')
34 .use('vue-svg-inline-loader')
35 .loader('vue-svg-inline-loader');
Ed Tanous7d6b44c2024-03-23 14:56:34 -070036
Ed Tanous511650a2024-04-20 16:36:00 -070037 config.module
38 .rule('ico')
39 .test(/\.ico$/)
40 .use('file-loader')
41 .loader('file-loader')
42 .options({
43 name: '[name].[contenthash:8].[ext]',
44 });
Ed Tanous1ccd8872024-04-21 17:02:30 -070045 config.plugins.delete('preload');
Ed Tanousb1daec62024-06-06 13:46:21 -070046 if (process.env.NODE_ENV === 'production') {
47 config.plugin('html').tap((options) => {
Ed Tanousa6c682c2024-07-17 10:42:38 -070048 options[0].filename = 'index.[contenthash:8].html';
Ed Tanousb1daec62024-06-06 13:46:21 -070049 return options;
50 });
51 }
Ed Tanousf8207742024-04-08 14:27:07 -070052 },
Derick Montague602e98a2020-10-21 16:20:00 -050053 configureWebpack: (config) => {
Ed Tanous740cbd52024-04-20 16:35:34 -070054 config.plugins.push(
55 new LimitChunkCountPlugin({
56 maxChunks: 1,
57 }),
58 );
59 config.optimization.splitChunks = {
60 cacheGroups: {
61 default: false,
62 },
63 };
Ed Tanousa6c682c2024-07-17 10:42:38 -070064 if (process.env.NODE_ENV === 'development') {
65 config.devtool = 'source-map';
66 }
Gunnar Mills99706ff2022-01-14 19:52:33 +000067 const crypto = require('crypto');
68 const crypto_orig_createHash = crypto.createHash;
69 crypto.createHash = (algorithm) =>
70 crypto_orig_createHash(algorithm == 'md4' ? 'sha256' : algorithm);
71
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080072 const envName = process.env.VUE_APP_ENV_NAME;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070073 const hasCustomStore = process.env.CUSTOM_STORE === 'true' ? true : false;
74 const hasCustomRouter = process.env.CUSTOM_ROUTER === 'true' ? true : false;
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070075 const hasCustomAppNav =
76 process.env.CUSTOM_APP_NAV === 'true' ? true : false;
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080077
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080078 if (envName !== undefined) {
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070079 if (hasCustomStore) {
Yoshie Muranaka816d9472020-09-03 11:19:28 -070080 // If env has custom store, resolve all store modules. Currently found
81 // in src/router/index.js src/store/api.js and src/main.js
82 config.resolve.alias['./store$'] = `@/env/store/${envName}.js`;
83 config.resolve.alias['../store$'] = `@/env/store/${envName}.js`;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070084 }
85 if (hasCustomRouter) {
Yoshie Muranaka816d9472020-09-03 11:19:28 -070086 // If env has custom router, resolve routes in src/router/index.js
87 config.resolve.alias['./routes$'] = `@/env/router/${envName}.js`;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070088 }
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070089 if (hasCustomAppNav) {
90 // If env has custom AppNavigation, resolve AppNavigationMixin module in src/components/AppNavigation/AppNavigation.vue
Ed Tanous81323992024-02-27 11:26:24 -080091 config.resolve.alias['./AppNavigationMixin$'] =
92 `@/env/components/AppNavigation/${envName}.js`;
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070093 }
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080094 }
Yoshie Muranaka816d9472020-09-03 11:19:28 -070095
96 if (process.env.NODE_ENV === 'production') {
97 config.plugins.push(
98 new CompressionPlugin({
Derick Montague602e98a2020-10-21 16:20:00 -050099 deleteOriginalAssets: true,
Ed Tanous81323992024-02-27 11:26:24 -0800100 }),
Yoshie Muranaka816d9472020-09-03 11:19:28 -0700101 );
102 }
Ed Tanous740cbd52024-04-20 16:35:34 -0700103
104 config.performance = {
105 hints: 'warning',
106 maxEntrypointSize: 512000,
107 maxAssetSize: 512000,
108 };
109
110 config.optimization.runtimeChunk = false;
Derick Montaguef3ab8bc2019-12-10 15:13:25 -0600111 },
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -0600112 pluginOptions: {
113 i18n: {
114 localeDir: 'locales',
Derick Montague602e98a2020-10-21 16:20:00 -0500115 enableInSFC: true,
116 },
117 },
Yoshie Muranaka74c24f12019-12-03 10:45:46 -0800118};