vue.config.js 1.4 KB

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