You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

66 lines
1.8 KiB

  1. /**
  2. * 配置参考:
  3. * https://cli.vuejs.org/zh/config/
  4. */
  5. // const url = 'http://pigx-gateway'
  6. const url = 'http://39.97.167.65/:9999' //测试
  7. // const url = 'http://192.168.31.161:9999' //长龙
  8. // const url = 'http://192.168.31.128:9999' //嘉豪
  9. const CompressionWebpackPlugin = require('compression-webpack-plugin')
  10. const productionGzipExtensions = ['js', 'css']
  11. module.exports = {
  12. lintOnSave: true,
  13. productionSourceMap: false,
  14. chainWebpack: config => {
  15. const entry = config.entry('app')
  16. entry
  17. .add('babel-polyfill')
  18. .end()
  19. entry
  20. .add('classlist-polyfill')
  21. .end()
  22. },
  23. css: {
  24. // 忽略 CSS order 顺序警告
  25. extract: { ignoreOrder: true }
  26. },
  27. configureWebpack: (config) => {
  28. if (process.env.NODE_ENV === 'production') {
  29. // 仅在生产环境下启用该配置
  30. return {
  31. performance: {
  32. // 打包后最大文件大小限制
  33. maxAssetSize: 1024000
  34. },
  35. plugins: [
  36. new CompressionWebpackPlugin({
  37. // filename: '[path].gz[query]',
  38. // algorithm: 'gzip',
  39. // test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  40. // threshold: 1024, // 只有大小大于该值的资源会被处理,当前配置为对于超过1k的数据进行处理,不足1k的可能会越压缩越大
  41. // minRatio: 0.99, // 只有压缩率小于这个值的资源才会被处理
  42. // deleteOriginalAssets: true // 删除原文件
  43. })
  44. ]
  45. }
  46. }
  47. },
  48. // 配置转发代理
  49. devServer: {
  50. disableHostCheck: true,
  51. port: 8080,
  52. proxy: {
  53. '/': {
  54. target: url,
  55. ws: false, // 需要websocket 开启
  56. pathRewrite: {
  57. '^/': '/'
  58. }
  59. },
  60. // 3.5 以后不需要再配置
  61. }
  62. }
  63. }