From 31b0b5c44444748a5ada241109057ea40320ca70 Mon Sep 17 00:00:00 2001 From: yurj26 <1816387074@qq.com> Date: Tue, 12 Dec 2023 15:10:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(nvue):=20vite=E9=85=8D=E7=BD=AEbuild.target?= =?UTF-8?q?=E4=B8=BAesnext=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84bug=20(quest?= =?UTF-8?q?ion/183180)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-app-vite/src/nvue/plugins/esbuild.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/uni-app-vite/src/nvue/plugins/esbuild.ts b/packages/uni-app-vite/src/nvue/plugins/esbuild.ts index a647b52aaf..ca3171181a 100644 --- a/packages/uni-app-vite/src/nvue/plugins/esbuild.ts +++ b/packages/uni-app-vite/src/nvue/plugins/esbuild.ts @@ -121,7 +121,10 @@ function buildAppCss() { const appCssJsCode = fs.readFileSync(appCssJsFilename, 'utf8') const appCssJsFn = new Function( 'module', - appCssJsCode.replace(`export default`, `module.exports=`) + // vite build.target为esnext时, 生成的代码没有export default + appCssJsCode.includes('export default') + ? appCssJsCode.replace(`export default`, `module.exports=`) + : appCssJsCode.replace(`exports`, `module.exports`) ) const module = { exports: { styles: [] } } appCssJsFn(module) -- GitLab