vue.config.js 3.1 KB

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