vue.config.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const { defineConfig } = require('@vue/cli-service')
  2. module.exports = defineConfig({
  3. transpileDependencies: true,
  4. lintOnSave:false,
  5. publicPath: "./", // 公共路径(必须有的)
  6. outputDir: "bigData", // 输出文件目录
  7. assetsDir: "static", //静态资源文件名称
  8. productionSourceMap: false, //去除打包后js的map文件
  9. devServer: { //启动项目在8080端口自动打开
  10. host:"127.0.0.1",
  11. open: true,
  12. port: 8888,
  13. //proxy: null,
  14. proxy: process.env.VUE_APP_ENV === 'production' ? 'https://www.aaa.com/' : 'https://gateway.bbb.com/'
  15. },
  16. chainWebpack(config) {
  17. config
  18. .when(process.env.VUE_APP_ENV !== 'www.dlc.com',
  19. config => {
  20. config
  21. .plugin('ScriptExtHtmlWebpackPlugin')
  22. .after('html')
  23. .use('script-ext-html-webpack-plugin', [{
  24. // `runtime` must same as runtimeChunk name. default is `runtime`
  25. inline: /runtime\..*\.js$/
  26. }])
  27. .end()
  28. config
  29. .optimization.splitChunks({
  30. chunks: 'all',
  31. minSize: 50000, //构建出来的chunk大于30000才会被分割
  32. maxSize: 100000, //会尝试根据这个大小进行代码分割
  33. // cacheGroups: {
  34. // libs: {
  35. // name: 'chunk-libs',
  36. // test: /[\\/]node_modules[\\/]/,
  37. // priority: 10,
  38. // chunks: 'initial'
  39. // },
  40. // elementUI: {
  41. // name: 'chunk-elementUI',
  42. // priority: 20,
  43. // test: /[\\/]node_modules[\\/]_?element-plus(.*)/,
  44. // chunks: 'initial'
  45. // },
  46. // echarts: {
  47. // name: 'chunk-echarts',
  48. // priority: 20,
  49. // test: /[\\/]node_modules[\\/]_?echarts(.*)/,
  50. // },
  51. // flv: {
  52. // name: 'chunk-flv',
  53. // priority: 20,
  54. // test: /[\\/]node_modules[\\/]_?flv(.*)/
  55. // },
  56. // jsJquery: {
  57. // name: 'chunk-jquery',
  58. // priority: 20,
  59. // test: /[\\/]node_modules[\\/]_?jquery(.*)/
  60. // },
  61. // mqtt: {
  62. // name: 'chunk-mqtt',
  63. // priority: 20,
  64. // test: /[\\/]node_modules[\\/]_?mqtt(.*)/
  65. // },
  66. // mqttPacket: {
  67. // name: 'chunk-mqtt-packet',
  68. // priority: 20,
  69. // test: /[\\/]node_modules[\\/]_?mqtt-packet(.*)/
  70. // },
  71. // }
  72. })
  73. }
  74. )
  75. },
  76. //去掉console
  77. // configureWebpack: (config) => {
  78. // // 判断为生产模式下,因为开发模式我们是想保存console的
  79. // if (process.env.NODE_ENV === "production") {
  80. // config.optimization.minimizer.map((arg) => {
  81. // const option = arg.options.terserOptions.compress;
  82. // option.drop_console = true; // 打开开关
  83. // return arg;
  84. // });
  85. // }
  86. // },
  87. // configureWebpack: {
  88. // // 关闭 webpack 的性能提示
  89. // // performance: {
  90. // // hints:false
  91. // // }
  92. //
  93. // // //或者
  94. //
  95. // // 警告 webpack 的性能提示
  96. // performance: {
  97. // hints: 'warning',
  98. // // 入口起点的最大体积
  99. // maxEntrypointSize: 50000000,
  100. // // 生成文件的最大体积
  101. // maxAssetSize: 30000000,
  102. // // 只给出 js 文件的性能提示
  103. // assetFilter: function (assetFilename) {
  104. // return assetFilename.endsWith('.js')
  105. // }
  106. // }
  107. // }
  108. })