vue.config.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const { defineConfig } = require("@vue/cli-service")
  2. module.exports = defineConfig({
  3. //设置为空打包后不分更目录还是多级目录
  4. publicPath: "/easydo/mes",
  5. outputDir: "easydo/mes",
  6. // publicPath: "/",
  7. // outputDir: "dist",
  8. //build编译后存放静态文件的目录
  9. // assetsDir: "static",
  10. // build编译后不生成资源MAP文件
  11. productionSourceMap: false,
  12. //开发服务,build后的生产模式还需nginx代理
  13. devServer: {
  14. allowedHosts: "all",
  15. open: false, //运行后自动打开浏览器
  16. port: process.env.VUE_APP_PORT, //挂载端口
  17. client: { overlay: false },
  18. proxy: {
  19. "/mes": {
  20. target: process.env.VUE_APP_MES_BASEURL,
  21. ws: true,
  22. pathRewrite: {
  23. "^/mes": ""
  24. }
  25. },
  26. "/minio": {
  27. target: process.env.VUE_APP_ZEROAPI_BASEURL,
  28. changeOrigin: true,
  29. pathRewrite: {}
  30. },
  31. "/iconify-api": {
  32. target: process.env.VUE_APP_ICONIFY_BASEURL,
  33. changeOrigin: true,
  34. pathRewrite: {
  35. "^/iconify-api": ""
  36. }
  37. }
  38. }
  39. },
  40. chainWebpack: config => {
  41. // 移除 prefetch 插件
  42. config.plugins.delete("preload");
  43. config.plugins.delete("prefetch");
  44. config.resolve.alias.set("vue-i18n", "vue-i18n/dist/vue-i18n.cjs.js");
  45. config.plugin("unplugin-auto-import").use(
  46. require("unplugin-auto-import/webpack").default({
  47. include: [
  48. /\.[tj]sx?$/,
  49. /\.vue$/,
  50. /\.vue\?vue/,
  51. /\.md$/
  52. ],
  53. imports: ["vue", "vuex", "vue-router"],
  54. eslintrc: {
  55. enabled: true,
  56. filepath: "./.eslintrc-auto-import.json",
  57. globalsPropValue: true
  58. },
  59. resolvers: [
  60. require("unplugin-vue-components/resolvers").ElementPlusResolver()
  61. ]
  62. })
  63. )
  64. config.plugin("unplugin-vue-components").use(
  65. require("unplugin-vue-components/webpack")({
  66. dirs: ["src/components/"],
  67. include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
  68. resolvers: [
  69. require("unplugin-vue-components/resolvers").ElementPlusResolver()
  70. ]
  71. })
  72. )
  73. },
  74. configureWebpack: {
  75. //性能提示
  76. performance: {
  77. hints: false
  78. },
  79. optimization: {
  80. splitChunks: {
  81. chunks: "all",
  82. automaticNameDelimiter: "~",
  83. name: "easyodoChunks",
  84. cacheGroups: {
  85. //第三方库抽离
  86. vendor: {
  87. name: "modules",
  88. test: /[\\/]node_modules[\\/]/,
  89. priority: -10
  90. },
  91. elicons: {
  92. name: "elicons",
  93. test: /[\\/]node_modules[\\/]@element-plus[\\/]icons-vue[\\/]/
  94. },
  95. echarts: {
  96. name: "echarts",
  97. test: /[\\/]node_modules[\\/]echarts[\\/]/
  98. },
  99. codemirror: {
  100. name: "codemirror",
  101. test: /[\\/]node_modules[\\/]codemirror[\\/]/
  102. }
  103. }
  104. }
  105. }
  106. }
  107. })