vue.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. const { defineConfig } = require("@vue/cli-service")
  2. module.exports = defineConfig({
  3. //设置为空打包后不分更目录还是多级目录
  4. publicPath: "",
  5. outputDir: "dist",
  6. //build编译后存放静态文件的目录
  7. //assetsDir: "static",
  8. // build编译后不生成资源MAP文件
  9. productionSourceMap: false,
  10. //开发服务,build后的生产模式还需nginx代理
  11. devServer: {
  12. allowedHosts: "all",
  13. open: false, //运行后自动打开浏览器
  14. port: process.env.VUE_APP_PORT, //挂载端口
  15. client: { overlay: false },
  16. proxy: {
  17. "/api": {
  18. target: process.env.VUE_APP_API_BASEURL,
  19. changeOrigin: true,
  20. ws: false,
  21. pathRewrite: {
  22. "^/api": "/api"
  23. }
  24. },
  25. "/minio": {
  26. target: process.env.VUE_APP_IMAGE_BASEURL,
  27. changeOrigin: true,
  28. ws: false,
  29. pathRewrite: {
  30. "^/minio": ""
  31. }
  32. }
  33. }
  34. },
  35. chainWebpack: config => {
  36. // 移除 prefetch 插件
  37. config.plugins.delete("preload");
  38. config.plugins.delete("prefetch");
  39. config.resolve.alias.set("vue-i18n", "vue-i18n/dist/vue-i18n.cjs.js");
  40. },
  41. configureWebpack: {
  42. //性能提示
  43. performance: {
  44. hints: false
  45. },
  46. optimization: {
  47. splitChunks: {
  48. chunks: "all",
  49. automaticNameDelimiter: "~",
  50. name: "scuiChunks",
  51. cacheGroups: {
  52. //第三方库抽离
  53. vendor: {
  54. name: "modules",
  55. test: /[\\/]node_modules[\\/]/,
  56. priority: -10
  57. },
  58. elicons: {
  59. name: "elicons",
  60. test: /[\\/]node_modules[\\/]@element-plus[\\/]icons-vue[\\/]/
  61. }
  62. }
  63. }
  64. }
  65. }
  66. })