!47 cdn打包支持pnpm,消除无external的报错

* <fix>cdn打包支持pnpm,消除无external的报错
This commit is contained in:
yujiacheng 2023-04-07 13:50:10 +00:00 committed by lyt-Top
parent 7544b23d7c
commit 8de54a844b

View File

@ -49,11 +49,11 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]', assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
manualChunks(id) { manualChunks(id) {
if (id.includes('node_modules')) { if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString(); return id.toString().match(/\/node_modules\/(?!.pnpm)(?<moduleName>[^\/]*)\//)?.groups.moduleName ?? 'vender';
} }
}, },
}, },
external: JSON.parse(env.VITE_OPEN_CDN) ? buildConfig.external : [], ...(JSON.parse(env.VITE_OPEN_CDN) ? {external: buildConfig.external} : {}),
}, },
}, },
css: { preprocessorOptions: { css: { charset: false } } }, css: { preprocessorOptions: { css: { charset: false } } },