| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame^] | 1 | const CompressionPlugin = require('compression-webpack-plugin'); | 
| Derick Montague | f3ab8bc | 2019-12-10 15:13:25 -0600 | [diff] [blame] | 2 |  | 
| Yoshie Muranaka | 74c24f1 | 2019-12-03 10:45:46 -0800 | [diff] [blame] | 3 | module.exports = { | 
|  | 4 | devServer: { | 
| Yoshie Muranaka | 6ce1a07 | 2019-12-06 14:13:59 -0800 | [diff] [blame] | 5 | proxy: { | 
| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame^] | 6 | '/': { | 
| Yoshie Muranaka | 6ce1a07 | 2019-12-06 14:13:59 -0800 | [diff] [blame] | 7 | target: process.env.BASE_URL, | 
|  | 8 | onProxyRes: proxyRes => { | 
| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame^] | 9 | if (proxyRes.headers['set-cookie']) { | 
| Yoshie Muranaka | 6ce1a07 | 2019-12-06 14:13:59 -0800 | [diff] [blame] | 10 | // Need to remove 'Secure' flag on set-cookie value so browser | 
|  | 11 | // can create cookie for local development | 
| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame^] | 12 | const cookies = proxyRes.headers['set-cookie'].map(cookie => | 
|  | 13 | cookie.replace(/; secure/gi, '') | 
| Yoshie Muranaka | 6ce1a07 | 2019-12-06 14:13:59 -0800 | [diff] [blame] | 14 | ); | 
| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame^] | 15 | proxyRes.headers['set-cookie'] = cookies; | 
| Yoshie Muranaka | 6ce1a07 | 2019-12-06 14:13:59 -0800 | [diff] [blame] | 16 | } | 
|  | 17 | } | 
|  | 18 | } | 
| Derick Montague | f3ab8bc | 2019-12-10 15:13:25 -0600 | [diff] [blame] | 19 | }, | 
|  | 20 | port: 8000 | 
|  | 21 | }, | 
|  | 22 | productionSourceMap: false, | 
|  | 23 | configureWebpack: config => { | 
| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame^] | 24 | if (process.env.NODE_ENV === 'production') { | 
| Derick Montague | f3ab8bc | 2019-12-10 15:13:25 -0600 | [diff] [blame] | 25 | config.plugins.push( | 
|  | 26 | new CompressionPlugin({ | 
|  | 27 | deleteOriginalAssets: true | 
|  | 28 | }) | 
|  | 29 | ); | 
|  | 30 | } | 
|  | 31 | }, | 
|  | 32 | chainWebpack: config => { | 
| Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame^] | 33 | if (process.env.NODE_ENV === 'production') { | 
|  | 34 | config.plugins.delete('prefetch'); | 
|  | 35 | config.plugins.delete('preload'); | 
| Yoshie Muranaka | 6ce1a07 | 2019-12-06 14:13:59 -0800 | [diff] [blame] | 36 | } | 
| Yoshie Muranaka | 74c24f1 | 2019-12-03 10:45:46 -0800 | [diff] [blame] | 37 | } | 
|  | 38 | }; |