blob: ba7d7c02b2e82c1350bfdbbb0c68a06d0de1fe91 [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 Tanous9c729792024-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 Tanous9c729792024-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 Tanous9c729792024-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) => {
48 options[0].filename = 'index.[hash:8].html';
49 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 Tanous9c729792024-03-23 14:56:34 -070064 config.devtool = 'source-map';
Gunnar Mills99706ff2022-01-14 19:52:33 +000065 const crypto = require('crypto');
66 const crypto_orig_createHash = crypto.createHash;
67 crypto.createHash = (algorithm) =>
68 crypto_orig_createHash(algorithm == 'md4' ? 'sha256' : algorithm);
69
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080070 const envName = process.env.VUE_APP_ENV_NAME;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070071 const hasCustomStore = process.env.CUSTOM_STORE === 'true' ? true : false;
72 const hasCustomRouter = process.env.CUSTOM_ROUTER === 'true' ? true : false;
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070073 const hasCustomAppNav =
74 process.env.CUSTOM_APP_NAV === 'true' ? true : false;
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080075
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080076 if (envName !== undefined) {
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070077 if (hasCustomStore) {
Yoshie Muranaka816d9472020-09-03 11:19:28 -070078 // If env has custom store, resolve all store modules. Currently found
79 // in src/router/index.js src/store/api.js and src/main.js
80 config.resolve.alias['./store$'] = `@/env/store/${envName}.js`;
81 config.resolve.alias['../store$'] = `@/env/store/${envName}.js`;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070082 }
83 if (hasCustomRouter) {
Yoshie Muranaka816d9472020-09-03 11:19:28 -070084 // If env has custom router, resolve routes in src/router/index.js
85 config.resolve.alias['./routes$'] = `@/env/router/${envName}.js`;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070086 }
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070087 if (hasCustomAppNav) {
88 // If env has custom AppNavigation, resolve AppNavigationMixin module in src/components/AppNavigation/AppNavigation.vue
Ed Tanous81323992024-02-27 11:26:24 -080089 config.resolve.alias['./AppNavigationMixin$'] =
90 `@/env/components/AppNavigation/${envName}.js`;
Yoshie Muranaka0214fed2020-09-03 13:25:50 -070091 }
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080092 }
Yoshie Muranaka816d9472020-09-03 11:19:28 -070093
94 if (process.env.NODE_ENV === 'production') {
95 config.plugins.push(
96 new CompressionPlugin({
Derick Montague602e98a2020-10-21 16:20:00 -050097 deleteOriginalAssets: true,
Ed Tanous81323992024-02-27 11:26:24 -080098 }),
Yoshie Muranaka816d9472020-09-03 11:19:28 -070099 );
100 }
Ed Tanous740cbd52024-04-20 16:35:34 -0700101
102 config.performance = {
103 hints: 'warning',
104 maxEntrypointSize: 512000,
105 maxAssetSize: 512000,
106 };
107
108 config.optimization.runtimeChunk = false;
Derick Montaguef3ab8bc2019-12-10 15:13:25 -0600109 },
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -0600110 pluginOptions: {
111 i18n: {
112 localeDir: 'locales',
Derick Montague602e98a2020-10-21 16:20:00 -0500113 enableInSFC: true,
114 },
115 },
Yoshie Muranaka74c24f12019-12-03 10:45:46 -0800116};