From 18224299aa10a1fb245ebf71ba647d3683377564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=8C=E7=B3=96=E5=8C=85=E5=AD=90?= Date: Sat, 11 Apr 2026 01:19:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20dev=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=20extract-css=20=E6=8F=92=E4=BB=B6=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=AF=BC=E8=87=B4=E7=9A=84=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dev 模式不加载 mini-css-extract-plugin,需先判断插件是否存在再调用 tap() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- vue.config.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vue.config.js b/vue.config.js index 6bae162..75cef9d 100644 --- a/vue.config.js +++ b/vue.config.js @@ -35,10 +35,13 @@ module.exports = defineConfig({ // Element Plus 按需导入时,不同路由 chunk 的 CSS 导入顺序不一致, // 但这不影响最终样式(specificity 规则优先),忽略该警告 - config.plugin('extract-css').tap(args => { - args[0].ignoreOrder = true - return args - }) + // extract-css 仅在生产构建时存在,dev 模式下跳过 + if (config.plugins.has('extract-css')) { + config.plugin('extract-css').tap(args => { + args[0].ignoreOrder = true + return args + }) + } }, devServer: { port: 8080,