vue.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. module.exports = {
  2. configureWebpack: {
  3. externals: {
  4. 'AMap': 'AMap' // 高德地图JS API
  5. }
  6. },
  7. //路径前缀
  8. publicPath: "/",
  9. lintOnSave: true,
  10. productionSourceMap: false,
  11. chainWebpack: (config) => {
  12. // 开启压缩js代码
  13. config.optimization.minimize(true)
  14. // 开启代码分割
  15. config.optimization.splitChunks({
  16. chunks: 'all',
  17. });
  18. //忽略的打包文件
  19. config.externals({
  20. 'vue': 'Vue',
  21. 'vue-router': 'VueRouter',
  22. 'vuex': 'Vuex',
  23. 'axios': 'axios',
  24. 'element-ui': 'ELEMENT',
  25. });
  26. const entry = config.entry('app');
  27. entry.add('babel-polyfill').end();
  28. entry.add('classlist-polyfill').end();
  29. entry.add('@/mock').end();
  30. },
  31. css: {
  32. extract: { ignoreOrder: true }
  33. },
  34. //开发模式反向代理配置,生产模式请使用Nginx部署并配置反向代理
  35. devServer: {
  36. port: 1024,
  37. proxy: {
  38. '/api': {
  39. //本地服务接口地址
  40. // target: 'http://192.168.3.64:1080',
  41. // target: 'http://192.168.8.106:1080',
  42. target: 'http://127.0.0.1:1080',
  43. // 打包地址
  44. // target: 'http://121.37.83.47:10004',//服务器ip
  45. // target: 'http://trade.tubaosoft.com:10004',//服务器域名
  46. ws: true,
  47. pathRewrite: {
  48. '^/api': '/'
  49. }
  50. }
  51. }
  52. }
  53. };