-
Notifications
You must be signed in to change notification settings - Fork 120
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
[Feature]: allow customize minify options #1681
Comments
Yeah we can remove the |
How about provide both minify?: {
/**
* Rspack is using swc minimizer, and the only builtin minimizer
* so we could pass the options directly.
* Not naming it to `js` as we might need `jsMinifier` or `cssMinifier` field to specify the minimizer in the future.
*/
js?: boolean | SwcJsMinimizerRspackPluginOptions;
/**
* Rspack is using swc to minimize CSS, which has not options for now.
* https://github.com/swc-project/swc/blob/main/crates/swc_css_minifier/src/options.rs#L6
* We could skip `cssOptions` field for now.
*/
css: boolean;
}; |
I did considering use that at first, which is much more prettier. But as described
I'm not sure whether we would provide an alternative builtin minimizer like Vite(https://vitejs.dev/config/build-options.html#build-minify), if so, there will an another field to specify the minimizer type or a more complex structure like If we're sticking to only one builtin minimizer for each kind of asset, we're good to use |
Currently we have no plans to support multiple minimizer types, and Rsbuild now supports different minimizers through plugins, such as CSS Minimizer Plugin. However, I cannot deny that Rsbuild may have multiple built-in minimizers in the future...
This is a bit complex and not friendly for config merging. Plain object can be better: type Output = {
minify?: {
/**
* Whether to enable JS minify.
*/
js?: boolean;
/**
* Rspack is using swc minimizer, and the only builtin minimizer
* so we could pass the options directly.
*/
jsOptions?: SwcJsMinimizerRspackPluginOptions;
/**
* Whether to enable CSS minify.
*/
css?: boolean;
/**
* Rspack is using swc to minimize CSS, which has not options for now.
* https://github.com/swc-project/swc/blob/main/crates/swc_css_minifier/src/options.rs#L6
* We could skip `cssOptions` field for now.
*/
};
}; |
LGTM, when we support alternative minimizer afterwards, we could set to |
Great 👍 |
What problem does this feature solve?
Currently, the only option of minify is
output.disableMinimize
, which is not allowed to pass options ofSwcJsMinimizerRspackPlugin
andSwcCssMinimizerRspackPlugin
to Rsbuild.What does the proposed API look like?
The implementation is easy, I could come up with a PR after the proposed API is passed.
The text was updated successfully, but these errors were encountered: