vue.config.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. const path = require('path')
  2. const CompressionPlugin = require('compression-webpack-plugin')
  3. const TerserPlugin = require("terser-webpack-plugin");
  4. function resolve(dir) {
  5. return path.join(__dirname, dir)
  6. }
  7. // var appData = require('./json/video.json')//加载本地数据文件
  8. // vue.config.js
  9. module.exports = {
  10. /*
  11. Vue-cli3:
  12. Crashed when using Webpack `import()` #2463
  13. https://github.com/vuejs/vue-cli/issues/2463
  14. */
  15. // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
  16. productionSourceMap: false,
  17. /*
  18. pages: {
  19. index: {
  20. entry: 'src/main.js',
  21. chunks: ['chunk-vendors', 'chunk-common', 'index']
  22. }
  23. },
  24. */
  25. configureWebpack: config => {
  26. if (process.env.NODE_ENV === 'production') {
  27. return {
  28. plugins: [new CompressionPlugin({
  29. test: /\.js$|\.html$|\.css/,
  30. threshold: 10240,
  31. deleteOriginalAssets: false
  32. }), new TerserPlugin({
  33. cache: true,//降版本后添加
  34. sourceMap: false,//降版本后添加
  35. // 多进程
  36. parallel: true,//降版本后添加
  37. terserOptions: {
  38. ecma: undefined,
  39. warnings: false,
  40. parse: {},
  41. compress: {
  42. drop_console: true,
  43. drop_debugger: false,
  44. pure_funcs: ['console.log'], // 移除console
  45. },
  46. },
  47. }),]
  48. }
  49. }
  50. },
  51. chainWebpack: (config) => {
  52. config.resolve.alias
  53. .set('@$', resolve('src'))
  54. .set('@base', resolve('src/base'))
  55. .set('@api', resolve('src/api'))
  56. .set('@assets', resolve('src/assets'))
  57. .set('@comp', resolve('src/components'))
  58. .set('@views', resolve('src/views'))
  59. .set('@layout', resolve('src/layout'))
  60. .set('@static', resolve('src/static'));
  61. config.plugins.delete('prefetch')
  62. },
  63. pluginOptions: {
  64. 'style-resources-loader': {
  65. preProcessor: 'less',
  66. patterns: [
  67. resolve('src/styles/var.less'),
  68. resolve('src/styles/mixin.less')
  69. ]
  70. }
  71. },
  72. css: {
  73. loaderOptions: {
  74. less: {
  75. modifyVars: {
  76. /* less 变量覆盖,用于自定义 ant design 主题 */
  77. /*
  78. 'primary-color': '#F5222D',
  79. 'link-color': '#F5222D',
  80. 'border-radius-base': '4px',
  81. */
  82. },
  83. javascriptEnabled: true,
  84. }
  85. }
  86. },
  87. devServer: {
  88. hot: true,
  89. // inline: true,
  90. port: 3000,
  91. open: true,
  92. proxy: {
  93. '/jeecg-boot': {
  94. // target: 'http://192.168.1.72:7001', //请求本地 需要jeecg-boot后台项目 蒙蒙
  95. // target: 'http://192.168.1.3:8080', //请求本地 需要jeecg-boot后台项目 蒙蒙
  96. // target: 'http://192.168.1.3:7001', //请求本地 需要jeecg-boot后台项目 蒙蒙
  97. // target: 'http://192.168.0.59:8088', //请求本地 需要jeecg-boot后台项目 英豪
  98. // target: 'http://192.168.1.62:7001', //请求本地 需要jeecg-boot后台项目 英豪
  99. // target: 'http://192.168.6.162:9806', //请求本地 需要jeecg-boot后台项目 祚云
  100. // target: 'http://192.168.1.43:8098', //请求本地 需要jeecg-boot后台项目 毕洁泉
  101. // target: 'http://192.168.1.43:8088', //请求本地 需要jeecg-boot后台项目 毕洁泉
  102. // target: 'http://192.168.1.43:8806', //请求本地 需要jeecg-boot后台项目 毕洁泉
  103. // target: 'http://192.168.0.252:8098', //请求本地 需要jeecg-boot后台项目 毕洁泉
  104. // target: 'http://192.168.1.59:7001', //请求本地 需要jeecg-boot后台项目 赵西安
  105. // target: 'http://192.168.1.193:8080', //请求本地 需要jeecg-boot后台项目 李煜一
  106. // target: 'http://192.168.1.193:31012', //请求本地 需要jeecg-boot后台项目 李煜一
  107. // target: 'http://api.tjyourong.com.cn', //请求本地 需要jeecg-boot后台项目
  108. // target: 'https://trac.tjyourong.com.cn', //请求本地 需要jeecg-boot后台项目
  109. // target: 'http://39.106.184.70:8088/', //请求本地 需要jeecg-boot后台项目
  110. // target: 'http://adsp.tjyourong.com.cn/', //请求本地 需要jeecg-boot后台项目
  111. // target: 'http://192.168.1.251/', //请求本地 需要jeecg-boot后台项目
  112. // target:'http://118.24.244.213:8804',
  113. // target: 'http://192.168.1.43:9999', // 子安
  114. // target: 'http://192.168.1.8:9999', // 学超
  115. target:'http://192.168.0.195:9999/',//测试
  116. ws: false,
  117. // changeOrigin: true,
  118. // pathRewrite: {
  119. // '/jeecg-boot': '' //默认所有请求都加了jeecg-boot前缀,需要去掉
  120. // }
  121. },
  122. },
  123. // before(app) {
  124. // app.get('/seller', (req, res) => {
  125. // res.json({
  126. // errno: 0,
  127. // data: appData
  128. // })//接口返回json数据,上面配置的数据seller就赋值给data请求后调用
  129. // })
  130. // }
  131. },
  132. lintOnSave: undefined,
  133. // publicPath:'./',
  134. }