blob: 1e17def04d5f978981e960422406e262192463bf [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 }
35 }
36 }
37 }
38 },
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,
44 onProxyRes: proxyRes => {
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060045 // This header is ignored in the browser so removing
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080046 // it so we don't see warnings in the browser console
47 delete proxyRes.headers['strict-transport-security'];
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080048 }
49 }
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060050 },
51 port: 8000
52 },
53 productionSourceMap: false,
54 configureWebpack: config => {
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080055 const envName = process.env.VUE_APP_ENV_NAME;
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070056 const hasCustomStore = process.env.CUSTOM_STORE === 'true' ? true : false;
57 const hasCustomRouter = process.env.CUSTOM_ROUTER === 'true' ? true : false;
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080058
Derick Montaguefded0d12019-12-11 06:16:40 -060059 if (process.env.NODE_ENV === 'production') {
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060060 config.plugins.push(
61 new CompressionPlugin({
62 deleteOriginalAssets: true
63 })
64 );
65 }
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070066
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080067 if (envName !== undefined) {
Yoshie Muranaka044b1bb2020-08-12 14:12:44 -070068 if (hasCustomStore) {
69 // If env has custom store, resolve store module in src/main.js
70 config.resolve.alias['./store$'] = `./env/store/${envName}.js`;
71 }
72 if (hasCustomRouter) {
73 // If env has custom router, resolve router module in src/main.js
74 config.resolve.alias['./router$'] = `./env/router/${envName}.js`;
75 }
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080076 }
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060077 },
78 chainWebpack: config => {
Derick Montaguefded0d12019-12-11 06:16:40 -060079 if (process.env.NODE_ENV === 'production') {
80 config.plugins.delete('prefetch');
81 config.plugins.delete('preload');
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080082 }
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060083 },
84 pluginOptions: {
85 i18n: {
86 localeDir: 'locales',
87 enableInSFC: true
88 }
Yoshie Muranaka74c24f12019-12-03 10:45:46 -080089 }
90};