blog-admin-web/vue.config.js
灌糖包子 e729ac1af2
fix: 过滤 dev overlay 中误报的 ResizeObserver loop 错误
ResizeObserver loop completed with undelivered notifications 是浏览器
规范允许的良性通知,Element Plus 下拉框展开时会触发,不影响实际功能。
webpack-dev-server 错误地将其当成运行时错误弹出 overlay,通过
client.overlay.runtimeErrors 回调将其过滤掉。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-11 01:32:55 +08:00

62 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const path = require('path')
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
const { defineConfig } = require('@vue/cli-service')
const { DefinePlugin } = require('webpack')
const { execSync } = require('child_process')
const commitInfo = execSync('git show -s --format=%cs%h').toString().trim()
module.exports = defineConfig({
publicPath: './',
transpileDependencies: true,
productionSourceMap: false,
configureWebpack: {
resolve: {
alias: { '@': path.resolve(__dirname, './src') }
},
plugins: [
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
new DefinePlugin({
'process.env.VERSION': `'${commitInfo}'`
})
]
},
chainWebpack: config => {
// fork-ts-checker-webpack-plugin v6 与 TypeScript 5 不兼容(无法覆写只读的 performance.mark
// 类型检查改由 tsc --noEmit 承担
config.plugins.delete('fork-ts-checker')
// Element Plus 按需导入时,不同路由 chunk 的 CSS 导入顺序不一致,
// 但这不影响最终样式specificity 规则优先),忽略该警告
// extract-css 仅在生产构建时存在dev 模式下跳过
if (config.plugins.has('extract-css')) {
config.plugin('extract-css').tap(args => {
args[0].ignoreOrder = true
return args
})
}
},
devServer: {
port: 8080,
client: {
overlay: {
// ResizeObserver loop 是浏览器规范允许的良性通知,不是真实错误,过滤掉避免干扰开发
runtimeErrors: (err) => err?.message !== 'ResizeObserver loop completed with undelivered notifications.'
}
},
proxy: {
'^/api': {
target: process.env.VUE_APP_PROXY_TARGET,
changeOrigin: true
}
}
}
})