blob: 9e1e1e1a93c3692b4a4facfb0d5872bd23f87bb1 [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 = {
4 devServer: {
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -08005 proxy: {
Derick Montaguefded0d12019-12-11 06:16:40 -06006 '/': {
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -08007 target: process.env.BASE_URL,
8 onProxyRes: proxyRes => {
Derick Montaguefded0d12019-12-11 06:16:40 -06009 if (proxyRes.headers['set-cookie']) {
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080010 // Need to remove 'Secure' flag on set-cookie value so browser
11 // can create cookie for local development
Derick Montaguefded0d12019-12-11 06:16:40 -060012 const cookies = proxyRes.headers['set-cookie'].map(cookie =>
13 cookie.replace(/; secure/gi, '')
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080014 );
Derick Montaguefded0d12019-12-11 06:16:40 -060015 proxyRes.headers['set-cookie'] = cookies;
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080016 }
17 }
18 }
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060019 },
20 port: 8000
21 },
22 productionSourceMap: false,
23 configureWebpack: config => {
Derick Montaguefded0d12019-12-11 06:16:40 -060024 if (process.env.NODE_ENV === 'production') {
Derick Montaguef3ab8bc2019-12-10 15:13:25 -060025 config.plugins.push(
26 new CompressionPlugin({
27 deleteOriginalAssets: true
28 })
29 );
30 }
31 },
32 chainWebpack: config => {
Derick Montaguefded0d12019-12-11 06:16:40 -060033 if (process.env.NODE_ENV === 'production') {
34 config.plugins.delete('prefetch');
35 config.plugins.delete('preload');
Yoshie Muranaka6ce1a072019-12-06 14:13:59 -080036 }
Yoshie Muranaka74c24f12019-12-03 10:45:46 -080037 }
38};