派生自 wuyushui/SewerAndRainNetwork

seatonwan9
2021-05-31 dd087d8c1b1406d8438d80e02a71cc77595e7e10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const appConfig = require('./src/app.config')
const path = require('path')
module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? `/${appConfig.projectName}/` : '/',
  configureWebpack: config => {
    config.name = appConfig.title
    config.resolve.alias = Object.assign(config.resolve.alias, require('./aliases.config').webpack)
    // 生产环境去掉注释及相关控制台信息方法
    if (process.env.NODE_ENV === 'production') {
      config.optimization.minimizer[0].options.extractComments = true
      config.optimization.minimizer[0].options.terserOptions.output.comments = false
      config.optimization.minimizer[0].options.terserOptions.compress.warnings = true
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
      config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
    }
  },
  parallel: require('os').cpus().length > 1, // 构建时开启多进程处理babel编译
  productionSourceMap: false,
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: [
        path.resolve(__dirname, './src/assets/css/map/_map-variable.less')
      ]
    }
  },
  devServer: {
    // host: 'localhost',
    // open: true,
    port: 8080,
    // overlay: false,
    overlay: {
      warnings: true,
      errors: true
    }
    // proxy: {
    //   '/hcstms': {
    //     target: 'http://10.238.221.113',
    //     changeOrigin: true,
    //     ws: true,
    //     pathRewrite: {
    //       '^/hcstms': ''
    //     }
    //   }
    // }
  }
}