<fix>cdn打包支持pnpm,消除无external的报错
原算法会将使用pnpm安装的项目中所有模块名错误匹配为.pnpm,且在关闭cdn打包时会报错:Unknown output options: external. Allowed options: amd, assetFileNames, banner, chunkFileNames, compact, dir, dynamicImportFunction, dynamicImportInCjs, entryFileNames, esModule, experimentalDeepDynamicChunkOptimization, experimentalMinChunkSize, exports, extend, externalImportAssertions, externalLiveBindings, file, footer, format, freeze, generatedCode, globals, hoistTransitiveImports, indent, inlineDynamicImports, interop, intro, manualChunks, minifyInternalExports, name, namespaceToStringTag, noConflict, outro, paths, plugins, preferConst, preserveModules, preserveModulesRoot, sanitizeFileName, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapIgnoreList, sourcemapPathTransform, strict, systemNullSetters, validate Signed-off-by: yujiacheng <cyj@programmer.net>
This commit is contained in:
parent
7544b23d7c
commit
d94b3f1482
|
|
@ -49,11 +49,11 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
|||
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
||||
manualChunks(id) {
|
||||
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 } } },
|
||||
|
|
|
|||
Loading…
Reference in New Issue