blob: 429b273e23761f5cd667e1c390ca7081ec5b4968 [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 Muranakadc04feb2019-12-04 08:41:22 -08004 css: {
5 loaderOptions: {
6 scss: {
7 prependData: `
8 @import "@/assets/styles/_obmc-custom.scss";
9 `
10 }
11 }
12 },
Yoshie Muranaka74c24f12019-12-03 10:45:46 -080013 devServer: {
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080014 https: true,
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080015 proxy: {
Derick Montaguefded0d12019-12-11 06:16:40 -060016 '/': {
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080017 target: process.env.BASE_URL,
18 onProxyRes: proxyRes => {
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080019 // This header is igorned in the browser so removing
20 // it so we don't see warnings in the browser console
21 delete proxyRes.headers['strict-transport-security'];
Derick Montaguefded0d12019-12-11 06:16:40 -060022 if (proxyRes.headers['set-cookie']) {
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080023 // Need to remove 'Secure' flag on set-cookie value so browser
24 // can create cookie for local development
Derick Montaguefded0d12019-12-11 06:16:40 -060025 const cookies = proxyRes.headers['set-cookie'].map(cookie =>
26 cookie.replace(/; secure/gi, '')
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080027 );
Derick Montaguefded0d12019-12-11 06:16:40 -060028 proxyRes.headers['set-cookie'] = cookies;
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080029 }
30 }
31 }
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060032 },
33 port: 8000
34 },
35 productionSourceMap: false,
36 configureWebpack: config => {
Derick Montaguefded0d12019-12-11 06:16:40 -060037 if (process.env.NODE_ENV === 'production') {
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060038 config.plugins.push(
39 new CompressionPlugin({
40 deleteOriginalAssets: true
41 })
42 );
43 }
44 },
45 chainWebpack: config => {
Derick Montaguefded0d12019-12-11 06:16:40 -060046 if (process.env.NODE_ENV === 'production') {
47 config.plugins.delete('prefetch');
48 config.plugins.delete('preload');
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080049 }
Yoshie Muranaka74c24f12019-12-03 10:45:46 -080050 }
51};