xref: /openbmc/webui-vue/vue.config.js (revision f65ee346)
1const CompressionPlugin = require('compression-webpack-plugin');
2
3module.exports = {
4  css: {
5    loaderOptions: {
6      scss: {
7        prependData: `
8          @import "@/assets/styles/_obmc-custom.scss";
9        `
10      }
11    }
12  },
13  devServer: {
14    https: true,
15    proxy: {
16      '/': {
17        target: process.env.BASE_URL,
18        onProxyRes: proxyRes => {
19          // 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'];
22          if (proxyRes.headers['set-cookie']) {
23            // Need to remove 'Secure' flag on set-cookie value so browser
24            // can create cookie for local development
25            const cookies = proxyRes.headers['set-cookie'].map(cookie =>
26              cookie.replace(/; secure/gi, '')
27            );
28            proxyRes.headers['set-cookie'] = cookies;
29          }
30        }
31      }
32    },
33    port: 8000
34  },
35  productionSourceMap: false,
36  configureWebpack: config => {
37    if (process.env.NODE_ENV === 'production') {
38      config.plugins.push(
39        new CompressionPlugin({
40          deleteOriginalAssets: true
41        })
42      );
43    }
44  },
45  chainWebpack: config => {
46    if (process.env.NODE_ENV === 'production') {
47      config.plugins.delete('prefetch');
48      config.plugins.delete('preload');
49    }
50  }
51};
52