Skip to content

Commit 3e7ad3f

Browse files
authored
fix(plugin-legacy): respect config.build.assetsDir (#1532)
close #1530
1 parent 49d294d commit 3e7ad3f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/plugin-legacy/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function viteLegacyPlugin(options = {}) {
8484
modernPolyfills,
8585
bundle,
8686
facadeToModernPolyfillMap,
87-
config.build.minify
87+
config.build
8888
)
8989
return
9090
}
@@ -114,7 +114,7 @@ function viteLegacyPlugin(options = {}) {
114114
facadeToLegacyPolyfillMap,
115115
// force using terser for legacy polyfill minification, since esbuild
116116
// isn't legacy-safe
117-
config.build.minify ? 'terser' : false
117+
config.build
118118
)
119119
}
120120
}
@@ -382,15 +382,17 @@ function detectPolyfills(code, targets, list) {
382382
* @param {Set<string>} imports
383383
* @param {import('rollup').OutputBundle} bundle
384384
* @param {Map<string, string>} facadeToChunkMap
385-
* @param {import('vite').BuildOptions['minify']} minify
385+
* @param {import('vite').BuildOptions} buildOptions
386386
*/
387387
async function buildPolyfillChunk(
388388
name,
389389
imports,
390390
bundle,
391391
facadeToChunkMap,
392-
minify
392+
buildOptions
393393
) {
394+
let { minify, assetsDir } = buildOptions
395+
minify = minify ? 'terser' : false
394396
const res = await build({
395397
// so that everything is resolved from here
396398
root: __dirname,
@@ -401,6 +403,7 @@ async function buildPolyfillChunk(
401403
write: false,
402404
target: false,
403405
minify,
406+
assetsDir,
404407
rollupOptions: {
405408
input: {
406409
[name]: polyfillId

0 commit comments

Comments
 (0)