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

docs: update minification guides #6297

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion website/components/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"banner-plugin-desc": "Support for this plugin was implemented in v0.3.3, before v0.3.3 you could use builtins.banner instead.",
"ignore-plugin-desc": "Recommend using rspack.IgnorePlugin instead.",
"mini-css-extract-plugin-desc": "use experiments.css or rspack.CssExtractRspackPlugin instead",
"terser-webpack-plugin-desc": "Use rspack.SwcJsMinimizerRspackPlugin or builtins.minifyOptions instead.",
"terser-webpack-plugin-desc": "Use rspack.SwcJsMinimizerRspackPlugin instead.",
"progress-plugin-desc": "use builtins.progress instead",
"tsconfig-paths-webpack-plugin-desc": "use resolve.tsconfigPath instead"
}
2 changes: 1 addition & 1 deletion website/components/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"banner-plugin-desc": "在 v0.3.3 已实现对该插件的支持,v0.3.3 之前可使用 builtins.banner 替代",
"ignore-plugin-desc": "推荐使用 rspack.IgnorePlugin 替代",
"mini-css-extract-plugin-desc": "使用 experiments.css 或 rspack.CssExtractRspackPlugin 替代",
"terser-webpack-plugin-desc": "使用 rspack.SwcJsMinimizerRspackPlugin 或 builtins.minifyOptions 替代",
"terser-webpack-plugin-desc": "使用 rspack.SwcJsMinimizerRspackPlugin 替代",
"progress-plugin-desc": "使用 builtins.progress 替代",
"tsconfig-paths-webpack-plugin-desc": "使用 resolve.tsconfigPath 替代"
}
19 changes: 18 additions & 1 deletion website/docs/en/guide/production.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,21 @@ It is recommended to enable SourceMap for production environments to facilitate

## Minification

Rspack uses the built-in minimizer to compress JavaScript and CSS code by default, which can be configured by [builtins.minifyOptions](config/builtins#builtinsminifyoptions). If the built-in minimizer cannot meet your needs, you can use [optimization.minimizer](config/optimization#optimizationminimizer) to set a custom minimizer.
During the production build, Rspack uses the built-in minimizer to minify JavaScript and CSS code by default. You can use [SwcJsMinimizerRspackPlugin](/plugins/rspack/swc-js-minimizer-rspack-plugin) for configuration.

```js title=rspack.config.js
const rspack = require('@rspack/core');

module.exports = {
optimization: {
minimizer: [
new rspack.SwcJsMinimizerRspackPlugin({
// JS minimizer configuration
}),
new rspack.SwcCssMinimizerRspackPlugin(),
],
},
};
```

If the built-in minimizer cannot meet your needs, you can also use [optimization.minimizer](/config/optimization#optimizationminimizer) to set custom minimizers.
19 changes: 18 additions & 1 deletion website/docs/zh/guide/production.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,21 @@

## 代码压缩

Rspack 默认使用内置的压缩器对 JavaScript 和 CSS 代码进行压缩,你可以使用 [builtins.minifyOptions](config/builtins#builtinsminifyoptions) 来进行配置。若内置压缩器无法满足需求,可以使用 [optimization.minimizer](config/optimization#optimizationminimizer) 设置自定义压缩器。
在执行生产构建时,Rspack 默认使用内置的压缩器对 JavaScript 和 CSS 代码进行压缩,你可以使用 [SwcJsMinimizerRspackPlugin](/plugins/rspack/swc-js-minimizer-rspack-plugin) 来进行配置。

```js title=rspack.config.js
const rspack = require('@rspack/core');

module.exports = {
optimization: {
minimizer: [
new rspack.SwcJsMinimizerRspackPlugin({
// JS minimizer 配置
}),
new rspack.SwcCssMinimizerRspackPlugin(),
],
},
};
```

如果内置压缩器无法满足需求,你也可以使用 [optimization.minimizer](/config/optimization#optimizationminimizer) 设置自定义压缩器。
Loading