From 313f9a20ef2b8655d2ad56293c8f0d144508d164 Mon Sep 17 00:00:00 2001 From: choysen <582511362@qq.com> Date: Thu, 14 Jan 2021 21:57:09 +0800 Subject: [PATCH 1/2] fix(legacy-plugin): respect config.build.assetsDir --- packages/plugin-legacy/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 1a6394b567daea..90d65e19bde3f5 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -84,7 +84,7 @@ function viteLegacyPlugin(options = {}) { modernPolyfills, bundle, facadeToModernPolyfillMap, - config.build.minify + config.build ) return } @@ -114,7 +114,7 @@ function viteLegacyPlugin(options = {}) { facadeToLegacyPolyfillMap, // force using terser for legacy polyfill minification, since esbuild // isn't legacy-safe - config.build.minify ? 'terser' : false + config.build ) } } @@ -382,15 +382,16 @@ function detectPolyfills(code, targets, list) { * @param {Set} imports * @param {import('rollup').OutputBundle} bundle * @param {Map} facadeToChunkMap - * @param {import('vite').BuildOptions['minify']} minify + * @param {import('vite').BuildOptions} buildOptions */ async function buildPolyfillChunk( name, imports, bundle, facadeToChunkMap, - minify + buildOptions ) { + const { minify, assetsDir } = buildOptions const res = await build({ // so that everything is resolved from here root: __dirname, @@ -401,6 +402,7 @@ async function buildPolyfillChunk( write: false, target: false, minify, + assetsDir, rollupOptions: { input: { [name]: polyfillId From 241912ee0e0fccf71c494063ad9e911640e07b18 Mon Sep 17 00:00:00 2001 From: choysen <582511362@qq.com> Date: Thu, 14 Jan 2021 22:03:19 +0800 Subject: [PATCH 2/2] fix(legacy-plugin): force using terser --- packages/plugin-legacy/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 90d65e19bde3f5..1c8020877301e2 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -391,7 +391,8 @@ async function buildPolyfillChunk( facadeToChunkMap, buildOptions ) { - const { minify, assetsDir } = buildOptions + let { minify, assetsDir } = buildOptions + minify = minify ? 'terser' : false const res = await build({ // so that everything is resolved from here root: __dirname,