vue.config.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. const { defineConfig } = require("@vue/cli-service")
  2. module.exports = defineConfig({
  3. //设置为空打包后不分更目录还是多级目录
  4. publicPath: '/easydo/aibox',
  5. outputDir: 'easydo/aibox',
  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. ws: true,
  20. pathRewrite: {
  21. "^/api": ""
  22. }
  23. },
  24. "/zeroapi": {
  25. target: process.env.VUE_APP_ZEROAPI_BASEURL,
  26. ws: true,
  27. pathRewrite: {}
  28. },
  29. "/minio": {
  30. target: process.env.VUE_APP_ZEROAPI_BASEURL,
  31. changeOrigin: true,
  32. pathRewrite: {}
  33. }
  34. }
  35. },
  36. chainWebpack: config => {
  37. // 移除 prefetch 插件
  38. config.plugins.delete("preload");
  39. config.plugins.delete("prefetch");
  40. config.resolve.alias.set("vue-i18n", "vue-i18n/dist/vue-i18n.cjs.js");
  41. config.plugin("unplugin-auto-import").use(
  42. require("unplugin-auto-import/webpack").default({
  43. include: [
  44. /\.[tj]sx?$/,
  45. /\.vue$/,
  46. /\.vue\?vue/,
  47. /\.md$/
  48. ],
  49. imports: ["vue", "vue-router"],
  50. eslintrc: {
  51. enabled: true,
  52. filepath: "./.eslintrc-auto-import.json",
  53. globalsPropValue: true
  54. },
  55. resolvers: [
  56. require("unplugin-vue-components/resolvers").ElementPlusResolver()
  57. ]
  58. })
  59. )
  60. config.plugin("unplugin-vue-components").use(
  61. require("unplugin-vue-components/webpack")({
  62. dirs: ["src/components/"],
  63. include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
  64. resolvers: [
  65. require("unplugin-vue-components/resolvers").ElementPlusResolver()
  66. ]
  67. })
  68. )
  69. },
  70. configureWebpack: {
  71. //性能提示
  72. performance: {
  73. hints: false
  74. },
  75. optimization: {
  76. splitChunks: {
  77. chunks: "all",
  78. automaticNameDelimiter: "~",
  79. name: "scuiChunks",
  80. cacheGroups: {
  81. //第三方库抽离
  82. vendor: {
  83. name: "modules",
  84. test: /[\\/]node_modules[\\/]/,
  85. priority: -10
  86. },
  87. elicons: {
  88. name: "elicons",
  89. test: /[\\/]node_modules[\\/]@element-plus[\\/]icons-vue[\\/]/
  90. },
  91. echarts: {
  92. name: "echarts",
  93. test: /[\\/]node_modules[\\/]echarts[\\/]/
  94. },
  95. codemirror: {
  96. name: "codemirror",
  97. test: /[\\/]node_modules[\\/]codemirror[\\/]/
  98. }
  99. }
  100. }
  101. }
  102. }
  103. })