mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-25 12:38:57 +02:00
feat(core): faster CSS minimizer - siteConfig.future.experimental_faster.lightningCssMinimizer
(#10522)
This commit is contained in:
parent
3b7c8281d5
commit
cba1e02772
12 changed files with 247 additions and 38 deletions
|
@ -5,6 +5,8 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import * as lightningcss from 'lightningcss';
|
||||
import browserslist from 'browserslist';
|
||||
import type {RuleSetRule} from 'webpack';
|
||||
import type {JsMinifyOptions} from '@swc/core';
|
||||
|
||||
|
@ -39,7 +41,7 @@ export function getSwcJsLoaderFactory({
|
|||
// They should rather be kept in sync for now to avoid any unexpected behavior
|
||||
// The goal of faster minifier is not to fine-tune options but only to be faster
|
||||
// See core minification.ts
|
||||
export function getSwcJsMinifierOptions(): JsMinifyOptions {
|
||||
export function getSwcJsMinimizerOptions(): JsMinifyOptions {
|
||||
return {
|
||||
ecma: 2020,
|
||||
compress: {
|
||||
|
@ -55,3 +57,16 @@ export function getSwcJsMinifierOptions(): JsMinifyOptions {
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
// LightningCSS doesn't expose any type for css-minimizer-webpack-plugin setup
|
||||
// So we derive it ourselves
|
||||
// see https://lightningcss.dev/docs.html#with-webpack
|
||||
type LightningCssMinimizerOptions = Omit<
|
||||
lightningcss.TransformOptions<never>,
|
||||
'filename' | 'code'
|
||||
>;
|
||||
|
||||
export function getLightningCssMinimizerOptions(): LightningCssMinimizerOptions {
|
||||
const queries = browserslist();
|
||||
return {targets: lightningcss.browserslistToTargets(queries)};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue