Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(legacy-plugin): respect config.build.assetsDir #1532

Merged
merged 2 commits into from
Jan 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/plugin-legacy/index.js
Original file line number Diff line number Diff line change
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