vue.config.js 2.8 KB

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