vue.config.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. const path = require('path')
  2. const CompressionPlugin = require("compression-webpack-plugin");
  3. function resolve(dir) {
  4. return path.join(__dirname, dir)
  5. }
  6. module.exports = {
  7. // outputDir:process.env.NODE_ENV === 'production' ? '小世系统(生产)' : '小世系统(本地)',
  8. runtimeCompiler: true ,
  9. publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
  10. lintOnSave: false,
  11. productionSourceMap: false,
  12. assetsDir: 'assets',
  13. // filenameHashing: false,
  14. // configureWebpack: () => {
  15. // if (process.env.NODE_ENV === 'production') {
  16. // return {
  17. // plugins: [
  18. // new CompressionPlugin({
  19. // test: /\.js$|\.html$|\.css$|\.jpg$|\.jpeg$|\.png/,
  20. // threshold: 10240,
  21. // deleteOriginalAssets: false
  22. // })
  23. // ]
  24. // }
  25. // }
  26. // },
  27. chainWebpack: config => {
  28. config.plugin('html')
  29. .tap(args => {
  30. args[0].title = '小世系统'
  31. // args[0].inlineSource = '(\.css|\.js$)'
  32. return args
  33. })
  34. // config.plugin('inline-source')
  35. // .use(require('html-webpack-inline-source-plugin'))
  36. config.plugins
  37. .delete('prefetch')
  38. .delete('preload')
  39. if (process.env.NODE_ENV === 'production') {
  40. // config.plugins.delete('html')
  41. }
  42. config.resolve.alias
  43. .set('@', path.join(__dirname, 'src'))
  44. config.module
  45. .rule('svg')
  46. .exclude.add(resolve('src/icons'))
  47. .end()
  48. config.module
  49. .rule('icons')
  50. .test(/\.svg$/)
  51. .include.add(resolve('src/icons'))
  52. .end()
  53. .use('svg-sprite-loader')
  54. .loader('svg-sprite-loader')
  55. .options({
  56. symbolId: 'icon-[name]'
  57. })
  58. .end()
  59. config
  60. .when(process.env.NODE_ENV !== 'development',
  61. config => {
  62. config
  63. .plugin('ScriptExtHtmlWebpackPlugin')
  64. .after('html')
  65. .use('script-ext-html-webpack-plugin', [{
  66. // `runtime` must same as runtimeChunk name. default is `runtime`
  67. inline: /runtime\..*\.js$/
  68. }])
  69. .end()
  70. config
  71. .optimization.splitChunks({
  72. chunks: 'all',
  73. minSize: 20000, // 允许新拆出 chunk 的最小体积,也是异步 chunk 公共模块的强制拆分体积
  74. maxAsyncRequests: 6, // 每个异步加载模块最多能被拆分的数量
  75. maxInitialRequests: 6, // 每个入口和它的同步依赖最多能被拆分的数量
  76. enforceSizeThreshold: 50000, // 强制执行拆分的体积阈值并忽略其他限制
  77. cacheGroups: {
  78. vue: {
  79. name: 'vue',
  80. test: /[\\/]node_modules[\\/]_?vue(.*)/,
  81. priority: 10,
  82. },
  83. elementUI: {
  84. name: 'element-ui', // split elementUI into a single package
  85. test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
  86. priority: 20 // the weight needs to be larger than libs and app or it will be packaged into libs or app
  87. },
  88. echarts: {
  89. name: 'echarts',
  90. test: /[\\/]node_modules[\\/]_?echarts(.*)/,
  91. priority: 30,
  92. },
  93. vendors: {
  94. name: 'vendors',
  95. test: /[\\/]node_modules[\\/]/,
  96. priority: -10,
  97. chunks: 'initial' // only package third parties that are initially dependent
  98. },
  99. }
  100. })
  101. config.optimization.runtimeChunk('single')
  102. }
  103. )
  104. },
  105. devServer: {
  106. port: 8087,
  107. overlay: {
  108. warnings: false,
  109. errors: false
  110. },
  111. proxy: {
  112. '/api/xiaoshi': {
  113. target: 'http://192.168.2.107:8879',
  114. // target: 'http://47.116.194.135:8879',
  115. ws: true,
  116. changeOrigin: true
  117. },
  118. '/fileManager': {
  119. target: 'http://192.168.2.24:8803',
  120. // target: 'http://192.168.2.105:8803',
  121. // target: 'http://47.116.194.135:8803',
  122. ws: true,
  123. changeOrigin: true,
  124. pathRewrite:{
  125. '/api':''
  126. }
  127. },
  128. '/service-image-url': {
  129. target: 'https://pss-system.cponline.cnipa.gov.cn',
  130. // target: 'https://www.xsip.cn',
  131. ws: true,
  132. changeOrigin: true,
  133. pathRewrite:{
  134. '/api':''
  135. }
  136. },
  137. '/permission': {
  138. target: 'http://192.168.2.24:8871',
  139. // target: 'http://192.168.2.109:8880',
  140. // target: 'http://47.116.194.135:8880',
  141. ws: true,
  142. changeOrigin: true,
  143. pathRewrite:{
  144. '/api':''
  145. }
  146. },
  147. '/fms':{
  148. target:'http://192.168.2.24:8803',
  149. // target: 'http://192.168.2.109:8803',
  150. // target: 'http://47.116.194.135:8803',
  151. ws:true,
  152. changeOrigin:true,
  153. pathRewrite:{
  154. '/api/fms':''
  155. }
  156. },
  157. '/v1':{
  158. target:'http://192.168.2.24',
  159. ws:true,
  160. changeOrigin:true,
  161. },
  162. }
  163. }
  164. }