vue.config.js 3.0 KB

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