blob: 817636222a5dcf9827cb58e8418476c1cdddd040 [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;
9 if (envName !== undefined) {
10 // If there is an env name defined, import Sass
11 // overrides.
12 // It is important that these imports stay in this
13 // order to make sure enviroment overrides
14 // take precedence over the default BMC styles
15 return `
16 @import "@/assets/styles/bmc/helpers";
17 @import "@/env/assets/styles/_${process.env.VUE_APP_ENV_NAME}";
18 @import "@/assets/styles/bootstrap/_helpers";
19 `;
20 } else {
21 // Include helper imports so single file components
22 // do not need to include helper imports
23
24 // BMC Helpers must be imported before Bootstrap helpers to
25 // take advantage of Bootstrap's use of the Sass !default
26 // statement. Moving this helper after results in Bootstrap
27 // variables taking precedence over BMC's
28 return `
29 @import "@/assets/styles/bmc/helpers";
30 @import "@/assets/styles/bootstrap/_helpers";
31 `;
32 }
33 }
34 }
35 }
36 },
Yoshie Muranaka74c24f12019-12-03 10:45:46 -080037 devServer: {
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080038 https: true,
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080039 proxy: {
Derick Montaguefded0d12019-12-11 06:16:40 -060040 '/': {
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080041 target: process.env.BASE_URL,
42 onProxyRes: proxyRes => {
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060043 // This header is ignored in the browser so removing
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080044 // it so we don't see warnings in the browser console
45 delete proxyRes.headers['strict-transport-security'];
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080046 }
47 }
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060048 },
49 port: 8000
50 },
51 productionSourceMap: false,
52 configureWebpack: config => {
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080053 const envName = process.env.VUE_APP_ENV_NAME;
54
Derick Montaguefded0d12019-12-11 06:16:40 -060055 if (process.env.NODE_ENV === 'production') {
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060056 config.plugins.push(
57 new CompressionPlugin({
58 deleteOriginalAssets: true
59 })
60 );
61 }
Yoshie Muranaka9e36f522020-02-05 07:42:34 -080062 if (envName !== undefined) {
63 // Resolve store and router modules in src/main.js
64 // depending on environment (VUE_APP_ENV_NAME) variable
65 config.resolve.alias['./store$'] = `./env/store/${envName}.js`;
66 config.resolve.alias['./router$'] = `./env/router/${envName}.js`;
67 }
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060068 },
69 chainWebpack: config => {
Derick Montaguefded0d12019-12-11 06:16:40 -060070 if (process.env.NODE_ENV === 'production') {
71 config.plugins.delete('prefetch');
72 config.plugins.delete('preload');
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080073 }
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060074 },
75 pluginOptions: {
76 i18n: {
77 localeDir: 'locales',
78 enableInSFC: true
79 }
Yoshie Muranaka74c24f12019-12-03 10:45:46 -080080 }
81};