vue.config.js 1.9 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. // 启用gzip
  24. },
  25. //路径前缀
  26. publicPath: "/",
  27. lintOnSave: true,
  28. productionSourceMap: false,
  29. chainWebpack: (config) => {
  30. //忽略的打包文件
  31. config.externals({
  32. 'vue': 'Vue',
  33. 'vue-router': 'VueRouter',
  34. 'vuex': 'Vuex',
  35. 'axios': 'axios',
  36. 'element-ui': 'ELEMENT',
  37. });
  38. const entry = config.entry('app');
  39. entry.add('babel-polyfill').end();
  40. entry.add('classlist-polyfill').end();
  41. entry.add('@/mock').end();
  42. },
  43. css: {
  44. extract: { ignoreOrder: true }
  45. },
  46. //开发模式反向代理配置,生产模式请使用Nginx部署并配置反向代理
  47. devServer: {
  48. port: 1024,
  49. proxy: {
  50. '/api': {
  51. //本地服务接口地址
  52. // target: 'http://localhost:1080',
  53. // target: 'http://192.168.3.64:1080',
  54. target: 'http://192.168.8.106:1080',
  55. // target: 'http://127.0.0.1:1080',
  56. // 打包地址
  57. // target: 'http://121.37.83.47:10004',//服务器ip
  58. // target: 'http://192.168.161.11:10004',//服务器ip
  59. // target: 'http://trade.tubaosoft.com:10004',//服务器域名
  60. ws: true,
  61. pathRewrite: {
  62. '^/api': '/'
  63. }
  64. }
  65. }
  66. }
  67. };