Skip to content

Commit

Permalink
feat(plugin-legacy): set build.cssMinifyTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Sep 29, 2021
1 parent 4a73ff2 commit 9f27073
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/plugin-legacy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ function viteLegacyPlugin(options = {}) {
if (!config.build) {
config.build = {}
}

if (!config.build.cssMinifyTarget) {
// Hint for esbuild that we are targeting legacy browsers when minifying CSS.
// Full CSS compat table available at https://github.com/evanw/esbuild/blob/78e04680228cf989bdd7d471e02bbc2c8d345dc9/internal/compat/css_table.go
// But note that only the `HexRGBA` feature affects the minify outcome.
// HSL & rebeccapurple values will be minified away regardless the target.
// So targeting `chrome61` suffices to fix the compatiblity issue.
config.build.cssMinifyTarget = 'chrome61'
}
}
}

Expand Down Expand Up @@ -125,7 +134,7 @@ function viteLegacyPlugin(options = {}) {
bundle,
facadeToModernPolyfillMap,
config.build,
options.externalSystemJS,
options.externalSystemJS
)
return
}
Expand Down Expand Up @@ -156,7 +165,7 @@ function viteLegacyPlugin(options = {}) {
// force using terser for legacy polyfill minification, since esbuild
// isn't legacy-safe
config.build,
options.externalSystemJS,
options.externalSystemJS
)
}
}
Expand Down

0 comments on commit 9f27073

Please sign in to comment.