Skip to content

Commit

Permalink
fix(plugin-legacy): respect config.build.assetsDir (#1532)
Browse files Browse the repository at this point in the history
close #1530
  • Loading branch information
CHOYSEN committed Jan 14, 2021
1 parent 49d294d commit 3e7ad3f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/plugin-legacy/index.js
Expand Up @@ -84,7 +84,7 @@ function viteLegacyPlugin(options = {}) {
modernPolyfills,
bundle,
facadeToModernPolyfillMap,
config.build.minify
config.build
)
return
}
Expand Down Expand Up @@ -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
)
}
}
Expand Down Expand Up @@ -382,15 +382,17 @@ function detectPolyfills(code, targets, list) {
* @param {Set<string>} imports
* @param {import('rollup').OutputBundle} bundle
* @param {Map<string, string>} facadeToChunkMap
* @param {import('vite').BuildOptions['minify']} minify
* @param {import('vite').BuildOptions} buildOptions
*/
async function buildPolyfillChunk(
name,
imports,
bundle,
facadeToChunkMap,
minify
buildOptions
) {
let { minify, assetsDir } = buildOptions
minify = minify ? 'terser' : false
const res = await build({
// so that everything is resolved from here
root: __dirname,
Expand All @@ -401,6 +403,7 @@ async function buildPolyfillChunk(
write: false,
target: false,
minify,
assetsDir,
rollupOptions: {
input: {
[name]: polyfillId
Expand Down

0 comments on commit 3e7ad3f

Please sign in to comment.