const CompressionWebpackPlugin = require('compression-webpack-plugin');
const DynamicAntdLess = require('ele-admin-pro/packages/style/dynamicTheme.js');

module.exports = {
  lintOnSave: false,
  productionSourceMap: false,
  transpileDependencies: ['ele-admin-pro'],
  chainWebpack: (config) => {
    config.plugins.delete('prefetch');
    if (process.env.NODE_ENV !== 'development') {
      // 生产环境进行gzip压缩
      config.plugin('compression-webpack-plugin').use(new CompressionWebpackPlugin({
        test: /\.(js|css|html)$/,
        threshold: 10240
      }));
    }
  },
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          javascriptEnabled: true,
          // plugins: [new DynamicAntdLess()]
          plugins: [new DynamicAntdLess({
            replaces: {
              'darken(@shadow-color, 5%)': '@shadow-color'
            }
          })]
        }
      }
    }
  },
  devServer: {
    //代理列表
    proxy: {
      '/api': {
          target: process.env.VUE_APP_API_BASE_URL, //要代理的域名
          changeOrigin: true,//允许跨域
          pathRewrite: {
            '^/api': ''  // 这个是定义要访问的路径，名字随便写
          }
      }
    }
  }
}
