xref: /openbmc/webui-vue/vue.config.js (revision 40865726)
1const CompressionPlugin = require('compression-webpack-plugin');
2
3module.exports = {
4  devServer: {
5    https: true,
6    proxy: {
7      '/': {
8        target: process.env.BASE_URL,
9        onProxyRes: proxyRes => {
10          // This header is ignored in the browser so removing
11          // it so we don't see warnings in the browser console
12          delete proxyRes.headers['strict-transport-security'];
13        }
14      }
15    },
16    port: 8000
17  },
18  productionSourceMap: false,
19  configureWebpack: config => {
20    const envName = process.env.VUE_APP_ENV_NAME;
21
22    if (process.env.NODE_ENV === 'production') {
23      config.plugins.push(
24        new CompressionPlugin({
25          deleteOriginalAssets: true
26        })
27      );
28    }
29    if (envName !== undefined) {
30      // Resolve store and router modules in src/main.js
31      // depending on environment (VUE_APP_ENV_NAME) variable
32      config.resolve.alias['./store$'] = `./env/store/${envName}.js`;
33      config.resolve.alias['./router$'] = `./env/router/${envName}.js`;
34    }
35  },
36  chainWebpack: config => {
37    if (process.env.NODE_ENV === 'production') {
38      config.plugins.delete('prefetch');
39      config.plugins.delete('preload');
40    }
41  },
42  pluginOptions: {
43    i18n: {
44      localeDir: 'locales',
45      enableInSFC: true
46    }
47  }
48};
49