vue.config.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. const CompressionPlugin = require('compression-webpack-plugin')
  2. const TerserPlugin = require('terser-webpack-plugin')
  3. module.exports = {
  4. devServer: {
  5. port: 8091,
  6. open: true,
  7. // 关闭esline
  8. overlay: {
  9. warnings: false,
  10. errors: false,
  11. },
  12. proxy: {
  13. '/wdfn': {
  14. target: 'http://map.wanda.cn',
  15. changeOrigin: true,
  16. pathRewrite: {
  17. '^/wdfn': '/editor',
  18. },
  19. },
  20. '/serve': {
  21. // target: 'http://192.168.200.87:8088/',
  22. // target: 'http://192.168.200.83:8085/',
  23. target: 'http://60.205.177.43:8080', //阿里云
  24. changeOrigin: true,
  25. secure: false,
  26. pathRewrite: {
  27. '^/serve': '',
  28. },
  29. },
  30. '/data': {
  31. // target: 'http://192.168.200.87:9003',
  32. target: 'http://60.205.177.43:9903', //阿里云
  33. changeOrigin: true,
  34. secure: false,
  35. pathRewrite: {
  36. '^/data': '/data',
  37. },
  38. },
  39. },
  40. },
  41. chainWebpack: (config) => {
  42. const svgRule = config.module.rule('svg')
  43. svgRule.uses.clear()
  44. svgRule
  45. .use('babel-loader')
  46. .loader('babel-loader')
  47. .end()
  48. .use('vue-svg-loader')
  49. .loader('vue-svg-loader')
  50. },
  51. lintOnSave: false,
  52. // publicPath: '/dist',
  53. publicPath: '/wandaTopol',
  54. // 打包名称
  55. outputDir: 'wandaTopol',
  56. // 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录
  57. assetsDir: 'static',
  58. productionSourceMap: false,
  59. // CSS 相关选项
  60. css: {
  61. // 将组件内的 CSS 提取到一个单独的 CSS 文件 (只用在生产环境中)
  62. extract: true,
  63. },
  64. // 配置webpack
  65. configureWebpack: (config) => {
  66. config.optimization = {
  67. minimize: true,
  68. minimizer: [
  69. new TerserPlugin({
  70. terserOptions: {
  71. // ecma: undefined,
  72. // warnings: false,
  73. // parse: {},
  74. compress: { drop_console: true },
  75. // mangle: true, // Note `mangle.properties` is `false` by default.
  76. // module: false,
  77. output: { comments: false },
  78. // toplevel: false,
  79. // nameCache: null,
  80. // ie8: false,
  81. // keep_classnames: undefined,
  82. // keep_fnames: false,
  83. // safari10: false,
  84. },
  85. }),
  86. ],
  87. }
  88. return {
  89. plugins: [
  90. // 压缩代码
  91. new CompressionPlugin({
  92. test: /\.js$|\.html$|.\css/, // 匹配文件名
  93. threshold: 10240, // 对超过10k的数据压缩
  94. deleteOriginalAssets: false, // true 不删除源文件 false 删除源文件
  95. }),
  96. ],
  97. }
  98. },
  99. }