Skip to content

Commit 42babe0

Browse files
committed
docs(cn): update content of terser-webpack-plugin
1 parent 88e7278 commit 42babe0

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

src/content/plugins/terser-webpack-plugin.mdx

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@ repo: https://github.com/webpack-contrib/terser-webpack-plugin
77
translators:
88
- 92hackers
99
- QC-L
10+
- Yucohny
1011
---
1112

12-
<div align="center">
13-
<a href="https://github.com/webpack/webpack">
14-
<img
15-
width="200"
16-
height="200"
17-
src="https://webpack.js.org/assets/icon-square-big.svg"
18-
/>
19-
</a>
20-
</div>
13+
免责声明:TerserWebpackPlugin 是由社区成员维护的第三方包,它可能没有与 webpack 相同的支持、安全策略或许可证,并且它不是由 webpack 维护的。
2114

2215
[![npm][npm]][npm-url]
2316
[![node][node]][node-url]
24-
[![deps][deps]][deps-url]
2517
[![tests][tests]][tests-url]
2618
[![cover][cover]][cover-url]
2719
[![chat][chat]][chat-url]
@@ -33,13 +25,13 @@ translators:
3325

3426
webpack v5 开箱即带有最新版本的 `terser-webpack-plugin`。如果你使用的是 webpack v5 或更高版本,同时希望自定义配置,那么仍需要安装 `terser-webpack-plugin`。如果使用 webpack v4,则必须安装 `terser-webpack-plugin` v4 的版本。
3527

36-
首先,你需要安装 `terser-webpack-plugin`
28+
首先需要安装 `terser-webpack-plugin`
3729

3830
```console
3931
npm install terser-webpack-plugin --save-dev
4032
```
4133

42-
然后将插件添加到你的 `webpack` 配置文件中例如:
34+
然后将插件添加到 `webpack` 配置文件中例如:
4335

4436
**webpack.config.js**
4537

@@ -56,28 +48,26 @@ module.exports = {
5648

5749
接下来,按照你习惯的方式运行 `webpack`
5850

59-
## 关于 source maps 说明 $#note-about-source-maps$
51+
## 关于 source map 的说明 $#note-about-source-maps$
6052

6153
**只对 [`devtool`](/configuration/devtool/) 选项的 `source-map``inline-source-map``hidden-source-map``nosources-source-map` 有效**
6254

6355
为何如此?
6456

65-
- `eval` 会包裹 modules,通过 `eval("string")`,而 minimizer 不会处理字符串
66-
- `cheap` 不存在列信息,minimizer 只产生单行,只会留下一个映射。
57+
- `eval` 通过 `eval("string")` 包裹模块而压缩工具不会处理字符串
58+
- `cheap` 不存在列信息而压缩工具输出的文件为单行文件,只会留下一个映射。
6759

6860
使用支持的 `devtool` 值可以生成 source map。
6961

7062
## 选项 $#options$
7163

72-
| 选项名 | 类型 | 默认值 | 描述 |
73-
| :---------------------------------------: | :-----------------------------------------------------------------------------: | :----------------------------------------------------------: | :------------------------------------------------------------------------- |
74-
| **[`test`](#test)** | `String\|RegExp\|Array<String\|RegExp>` | `/\.m?js(\?.*)?$/i` | 用来匹配需要压缩的文件。 |
75-
| **[`include`](#include)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | 匹配参与压缩的文件。 |
76-
| **[`exclude`](#exclude)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | 匹配不需要压缩的文件。 |
77-
| **[`parallel`](#parallel)** | `Boolean\|Number` | `true` | 使用多进程并发运行以提高构建速度。 |
78-
| **[`minify`](#minify)** | `Function` | `TerserPlugin.terserMinify` | 允许你自定义压缩函数。 |
79-
| **[`terserOptions`](#terseroptions)** | `Object` | [`default`](https://github.com/terser/terser#minify-options) | Terser 的 [minify 选项](https://github.com/terser/terser#minify-options)|
80-
| **[`extractComments`](#extractcomments)** | `Boolean\|String\|RegExp\|Function<(node, comment) -> Boolean\|Object>\|Object` | `true` | 注释是否需要提取到一个单独的文件中。 |
64+
- **[`test`](#test)**
65+
- **[`include`](#include)**
66+
- **[`exclude`](#exclude)**
67+
- **[`parallel`](#parallel)**
68+
- **[`minify`](#minify)**
69+
- **[`terserOptions`](#terseroptions)**
70+
- **[`extractComments`](#extractcomments)**
8171

8272
### `test` $#test$
8373

0 commit comments

Comments
 (0)