xref: /openbmc/webui-vue/vue.config.js (revision 75100469)
1const CompressionPlugin = require('compression-webpack-plugin');
2
3module.exports = {
4  css: {
5    loaderOptions: {
6      sass: {
7        prependData: () => {
8          const envName = process.env.VUE_APP_ENV_NAME;
9          if (envName !== undefined) {
10            // If there is an env name defined, import Sass
11            // overrides.
12            // It is important that these imports stay in this
13            // order to make sure enviroment overrides
14            // take precedence over the default BMC styles
15            return `
16              @import "@/assets/styles/bmc/helpers";
17              @import "@/env/assets/styles/_${process.env.VUE_APP_ENV_NAME}";
18              @import "@/assets/styles/bootstrap/_helpers";
19            `;
20          } else {
21            // Include helper imports so single file components
22            // do not need to include helper imports
23
24            // BMC Helpers must be imported before Bootstrap helpers to
25            // take advantage of Bootstrap's use of the Sass !default
26            // statement. Moving this helper after results in Bootstrap
27            // variables taking precedence over BMC's
28            return `
29              @import "@/assets/styles/bmc/helpers";
30              @import "@/assets/styles/bootstrap/_helpers";
31            `;
32          }
33        }
34      }
35    }
36  },
37  devServer: {
38    https: true,
39    proxy: {
40      '/': {
41        target: process.env.BASE_URL,
42        onProxyRes: proxyRes => {
43          // This header is ignored in the browser so removing
44          // it so we don't see warnings in the browser console
45          delete proxyRes.headers['strict-transport-security'];
46        }
47      }
48    },
49    port: 8000
50  },
51  productionSourceMap: false,
52  configureWebpack: config => {
53    const envName = process.env.VUE_APP_ENV_NAME;
54
55    if (process.env.NODE_ENV === 'production') {
56      config.plugins.push(
57        new CompressionPlugin({
58          deleteOriginalAssets: true
59        })
60      );
61    }
62    if (envName !== undefined) {
63      // Resolve store and router modules in src/main.js
64      // depending on environment (VUE_APP_ENV_NAME) variable
65      config.resolve.alias['./store$'] = `./env/store/${envName}.js`;
66      config.resolve.alias['./router$'] = `./env/router/${envName}.js`;
67    }
68  },
69  chainWebpack: config => {
70    if (process.env.NODE_ENV === 'production') {
71      config.plugins.delete('prefetch');
72      config.plugins.delete('preload');
73    }
74  },
75  pluginOptions: {
76    i18n: {
77      localeDir: 'locales',
78      enableInSFC: true
79    }
80  }
81};
82