7
0

vue.config.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. const { defineConfig } = require('@vue/cli-service')
  2. const path = require('path')
  3. const webpack = require('webpack')
  4. const CompressionWebpackPlugin = require("compression-webpack-plugin");
  5. function resolve(dir) {
  6. return path.join(__dirname, dir)
  7. }
  8. module.exports = defineConfig({
  9. transpileDependencies: true,
  10. publicPath: "/kdyjs/",
  11. pages: {
  12. index: {
  13. // page 的入口
  14. entry: 'src/main.js',
  15. // 模板来源
  16. template: 'public/index.html',
  17. // 在 dist/index.html 的输出
  18. filename: 'index.html',
  19. // 当使用 title 选项时,
  20. // template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
  21. title: '开店一件事',
  22. // 在这个页面中包含的块,默认情况下会包含
  23. // 提取出来的通用 chunk 和 vendor chunk。
  24. chunks: ['chunk-vendors', 'chunk-common', 'index']
  25. }
  26. },
  27. // ...other config
  28. configureWebpack: config => {
  29. config.performance = {
  30. hints: 'warning',
  31. //入口起点的最大体积 整数类型(以字节为单位)
  32. maxEntrypointSize: 50000000,
  33. //生成文件的最大体积 整数类型(以字节为单位 300k)
  34. maxAssetSize: 30000000,
  35. //只给出 js 文件的性能提示
  36. assetFilter: function (assetFilename) {
  37. return assetFilename.endsWith('.js')
  38. }
  39. }
  40. const plugins = [];
  41. // 同externals一样,我们只想在生产环境下生成gzip即可
  42. if (process.env.NODE_ENV === 'production') {
  43. plugins.push(
  44. new CompressionWebpackPlugin({
  45. filename: '[path][base].gz[query]', // 生成的文件名
  46. algorithm: 'gzip', // 类型
  47. test: new RegExp('\\.(js|css)$'), // 匹配规则
  48. threshold: 10240, // 字节数 只处理比这个大的资源
  49. minRatio: 0.8, // 压缩率 只有比这个小的才会处理
  50. // 是否删除源文件,默认: false
  51. deleteOriginalAssets: false
  52. })
  53. )
  54. }
  55. config.plugins = [
  56. ...config.plugins,
  57. ...plugins
  58. ]
  59. // 增加加载 .geojson 文件的规则
  60. let rules = [{
  61. test: /\.geojson$/,
  62. loader: 'json-loader'
  63. }]
  64. config.module.rules = [
  65. ...config.module.rules,
  66. ...rules
  67. ]
  68. },
  69. productionSourceMap: false, //打包不生成js.map文件
  70. chainWebpack: (config) => {
  71. config.resolve.alias
  72. .set('@$', resolve('src'))
  73. .set('@static', resolve('public/static'))
  74. },
  75. pluginOptions: {
  76. "style-resources-loader": {
  77. preProcessor: "less",
  78. patterns: [
  79. path.resolve(__dirname, 'src/assets/less/variable.less')
  80. ]
  81. }
  82. },
  83. devServer: {
  84. port: 2118,
  85. client: {
  86. overlay: false
  87. },
  88. proxy: {
  89. '/proxy_auth': {
  90. target: 'http://121.43.55.7:10086/',
  91. changeOrigin: true,
  92. pathRewrite: {
  93. '^/proxy_auth': ''
  94. }
  95. },
  96. '/proxy_kdyjs': {
  97. target: 'http://121.43.55.7:10018/',
  98. changeOrigin: true,
  99. pathRewrite: {
  100. '^/proxy_kdyjs': ''
  101. }
  102. },
  103. '/proxy_proxy': {
  104. target: 'http://121.43.55.7:10011/',
  105. changeOrigin: true,
  106. pathRewrite: {
  107. '^/proxy_proxy': ''
  108. }
  109. },
  110. '/proxy_dms': {
  111. target: 'http://121.43.55.7:10081/',
  112. changeOrigin: true,
  113. pathRewrite: {
  114. '^/proxy_dms': ''
  115. }
  116. },
  117. '/proxy_zwdt': {
  118. target: 'https://szlszxdt.qpservice.org.cn/',
  119. changeOrigin: true,
  120. pathRewrite: {
  121. '^/proxy_zwdt': ''
  122. }
  123. },
  124. },
  125. }
  126. })