From 7b836fcb7d08b5ea9cc04333a9cacc98788c95ac Mon Sep 17 00:00:00 2001 From: hooray <304327508@qq.com> Date: Fri, 6 May 2022 02:20:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=97=B6=E8=A7=A3=E5=86=B3element=20p?= =?UTF-8?q?lus=E6=8C=89=E9=9C=80=E8=BD=BD=E5=85=A5=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=AF=B9=E5=BA=94=E7=9A=84=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BC=9A=E5=AF=BC=E8=87=B4vite=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E9=87=8D=E8=BD=BD=E9=A1=B5=E9=9D=A2=E5=B9=B6=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=BE=88=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.js | 12 ++++++++++++ vite/plugins/components.js | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/vite.config.js b/vite.config.js index 2b59b1d9..310694bb 100644 --- a/vite.config.js +++ b/vite.config.js @@ -21,6 +21,15 @@ export default ({ mode, command }) => { scssResources.push(`@import "src/assets/sprites/_${dirname}.scss";`) } }) + // BUG https://github.com/element-plus/element-plus/issues/4916 + const optimizeDepsElementPlusIncludes = ['element-plus/es'] + fs.readdirSync('node_modules/element-plus/es/components').map(dirname => { + fs.access(`node_modules/element-plus/es/components/${dirname}/style/css.mjs`, err => { + if (!err) { + optimizeDepsElementPlusIncludes.push(`element-plus/es/components/${dirname}/style/css`) + } + }) + }) return defineConfig({ base: './', // 开发服务器选项 https://cn.vitejs.dev/config/#server-options @@ -46,6 +55,9 @@ export default ({ mode, command }) => { } } }, + optimizeDeps: { + include: optimizeDepsElementPlusIncludes + }, plugins: createVitePlugins(env, command === 'build'), resolve: { alias: { diff --git a/vite/plugins/components.js b/vite/plugins/components.js index e044e457..0e2e47ee 100644 --- a/vite/plugins/components.js +++ b/vite/plugins/components.js @@ -7,6 +7,7 @@ export default function createComponents() { ElementPlusResolver() ], dirs: ['src/components'], - include: [/\.vue$/, /\.vue\?vue/, /\.jsx$/] + include: [/\.vue$/, /\.vue\?vue/, /\.jsx$/], + dts: false }) }