vue.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const path = require("path");
  2. const webpack = require("webpack");
  3. function resolve(dir) {
  4. return path.join(__dirname, dir);
  5. }
  6. let timeStamp = new Date().getTime();
  7. // 添加historyApiFallback配置后可能会导致的内存溢出异常添加默认配置可避免
  8. require('events').EventEmitter.defaultMaxListeners = 0;
  9. // vue.config.js
  10. module.exports = {
  11. publicPath: "./",
  12. filenameHashing: false,
  13. // 打包配置
  14. configureWebpack: {
  15. output: {
  16. // 输出重构 打包编译后的js文件名称,添加时间戳.
  17. filename: `js/js[name].${timeStamp}.js`,
  18. chunkFilename: `js/chunk.[id].${timeStamp}.js`,
  19. },
  20. },
  21. css: {
  22. extract: {
  23. // 打包后css文件名称添加时间戳
  24. filename: `css/[name].${timeStamp}.css`,
  25. chunkFilename: `css/chunk.[id].${timeStamp}.css`,
  26. },
  27. },
  28. chainWebpack: (config) => {
  29. config.resolve.alias
  30. .set("@$", resolve("src"))
  31. .set("@static", resolve("public/static"));
  32. },
  33. devServer: {
  34. // https: true,
  35. port: 2024,
  36. // 路由模式为history时出现的404异常,需要添加配置
  37. historyApiFallback: {
  38. index: '/index.html'
  39. },
  40. proxy: {
  41. "/proxy_searchByName": {
  42. target: "http://121.43.55.7:10011/proxy",
  43. changeOrigin: true, // 允许跨域
  44. pathRewrite: {
  45. "^/proxy_searchByName": "/searchByName",
  46. },
  47. },
  48. "/oauth": {
  49. target: "http://121.43.55.7:2100",
  50. changeOrigin: true, // 允许跨域
  51. pathRewrite: {
  52. "^/oauth": "/proxy_oauth",
  53. },
  54. },
  55. "/dms": {
  56. target: "http://121.43.55.7:2101",
  57. changeOrigin: true, // 允许跨域
  58. pathRewrite: {
  59. "^/dms": "/proxy_dms",
  60. },
  61. },
  62. },
  63. },
  64. };