vue.config.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. const webpack = require('webpack')
  2. const CompressionWebpackPlugin = require('compression-webpack-plugin')
  3. const productionGzipExtensions = ['js', 'css']
  4. module.exports = {
  5. configureWebpack: {
  6. externals: {
  7. 'AMap': 'AMap' // 高德地图JS API
  8. },
  9. // 启用gzip
  10. plugins: [
  11. new CompressionWebpackPlugin({
  12. algorithm: 'gzip',
  13. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  14. threshold: 10240,
  15. minRatio: 0.8,
  16. deleteOriginalAssets: false // 是否删除源文件
  17. }),
  18. new webpack.optimize.LimitChunkCountPlugin({
  19. maxChunks: 5,
  20. minChunkSize: 100
  21. })
  22. ]
  23. },
  24. //路径前缀
  25. publicPath: "/",
  26. lintOnSave: true,
  27. productionSourceMap: false,
  28. chainWebpack: (config) => {
  29. //忽略的打包文件
  30. config.externals({
  31. 'vue': 'Vue',
  32. 'vue-router': 'VueRouter',
  33. 'vuex': 'Vuex',
  34. 'axios': 'axios',
  35. 'element-ui': 'ELEMENT',
  36. });
  37. const entry = config.entry('app');
  38. entry.add('babel-polyfill').end();
  39. entry.add('classlist-polyfill').end();
  40. entry.add('@/mock').end();
  41. },
  42. css: {
  43. extract: { ignoreOrder: true }
  44. },
  45. //开发模式反向代理配置,生产模式请使用Nginx部署并配置反向代理
  46. devServer: {
  47. port: 1024,
  48. proxy: {
  49. '/api': {
  50. //本地服务接口地址
  51. // target: 'http://192.168.3.64:1080',
  52. // target: 'http://192.168.8.104:1080',
  53. // target: 'http://127.0.0.1:1080',
  54. // 打包地址
  55. target: 'http://121.37.83.47:10004',//服务器ip
  56. // target: 'http://192.168.161.11:10004',//服务器ip
  57. // target: 'http://127.0.0.1:10004',
  58. // target: 'http://trade.tubaosoft.com:10004',//服务器域名
  59. ws: true,
  60. pathRewrite: {
  61. '^/api': '/'
  62. }
  63. }
  64. }
  65. }
  66. };