vue.config.js 1.6 KB

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