Skip to content

Commit b7945b4

Browse files
AlenQialaddin-add
authored andcommitted
translated /content/plugins/babel-minify-webpack-plugin.md (#376)
* translate done * fixed detail fixed detail
1 parent 3c6e31e commit b7945b4

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/content/plugins/babel-minify-webpack-plugin.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ edit: https://github.com/webpack-contrib/babel-minify-webpack-plugin/edit/master
55
repo: https://github.com/webpack-contrib/babel-minify-webpack-plugin
66
---
77

8-
<p>A Webpack Plugin for <a href="https://github.com/babel/minify">babel-minify</a> - A babel based minifier<p>
8+
<p>一个用于<a href="https://github.com/babel/minify">babel-minify</a>的Webpack插件<p>
99
</div>
1010

11-
## Install
11+
## 安装
1212

1313
```bash
1414
npm install babel-minify-webpack-plugin --save-dev
1515
```
1616

17-
## Usage
17+
## 用法
1818

1919
```js
2020
// webpack.config.js
@@ -28,33 +28,33 @@ module.exports = {
2828
}
2929
```
3030

31-
## Options
31+
## 选项
3232

3333
#### minifyOpts
3434

35-
`minifyOpts` are passed on to babel-preset-minify. You can find a list of [all available options](https://github.com/babel/minify/tree/master/packages/babel-preset-minify#options) in the package directory.
35+
`minifyOpts` 被传递给 babel-preset-minify。 你可以在包目录中找到[所有可用的选项](https://github.com/babel/minify/tree/master/packages/babel-preset-minify#options)
3636

3737
`Default: {}`
3838

3939
#### pluginOpts
4040

41-
+ `test`: JS file extension regex. Default: `/\.js($|\?)/i`
42-
+ `comments`: Preserve Comments. Default: `/^\**!|@preserve|@license|@cc_on/`, falsy value to remove all comments. Accepts function, object with property test (regex), and values.
43-
+ `sourceMap`: Default: uses [webpackConfig.devtool](https://webpack.js.org/configuration/devtool/). Set this to override that.
44-
+ `parserOpts`: Configure babel with special parser options.
45-
+ `babel`: Pass in a custom babel-core instead. `require("babel-core")`
46-
+ `minifyPreset`: Pass in a custom minify preset instead - `require("babel-preset-minify")`.
41+
+ `test`: JS文件扩展名正则表达式。 默认: `/\.js($|\?)/i`
42+
+ `comments`: 保留注释。 默认: `/^\**!|@preserve|@license|@cc_on/`, `falsy` 值将移除所有注释。可以接受函数,带有测试属性的(正则)的对象和值。
43+
+ `sourceMap`: 默认: 使用 [webpackConfig.devtool](https://webpack.js.org/configuration/devtool/)。 这里的设置会覆写`devtool`的设置。
44+
+ `parserOpts`: 配置具有特殊解析器选项的babel。
45+
+ `babel`: 传入一个自定义的 babel-core,代替原来的。 `require("babel-core")`
46+
+ `minifyPreset`: 传入一个自定义的 minify preset,代替原来的。 - `require("babel-preset-minify")`.
4747

48-
## Why
48+
## 为什么
4949

50-
You can also use [babel-loader](https://github.com/babel/babel-loader) for webpack and include `minify` [as a preset](https://github.com/babel/minify#babel-preset) and should be much faster than using this - as babel-minify will operate on smaller file sizes. But then, why does this plugin exist at all? -
50+
你也可以在webpack中使用[babel-loader](https://github.com/babel/babel-loader),引入 `minify` [作为一个预设](https://github.com/babel/minify#babel-preset)并且应该运行的更快 - 因为 `babel-minify` 将运行在更小的文件。但是,这个插件为什么还存在呢?
5151

52-
+ A webpack loader operates on single files and the minify preset as a webpack loader is going to consider each file to be executed directly in the browser global scope (by default) and will not optimize some things in the toplevel scope. To enable optimizations to take place in the top level scope of the file, use `topLevel: true` in minifyOptions.
53-
+ When you exclude `node_modules` from being run through the babel-loader, babel-minify optimizations are not applied to the excluded files as it doesn't pass through the minifier.
54-
+ When you use the babel-loader with webpack, the code generated by webpack for the module system doesn't go through the loader and is not optimized by babel-minify.
55-
+ A webpack plugin can operate on the entire chunk/bundle output and can optimize the whole bundle and you can see some differences in minified output. But this will be a lot slower as the file size is usually really huge. So there is [another idea](https://github.com/webpack-contrib/babel-minify-webpack-plugin/issues/8) where we can apply some optimizations as a part of the loader and some optimizations in a plugin.
52+
+ webpack loader对单个文件进行操作,并且minify preset作为一个webpack loader将会把每个文件视为在浏览器全局范围内直接执行(默认情况下),并且不会优化顶级作用域内的某些内容。要在文件的顶级作用域内进行优化,请在minifyOptions中设置 `topLeveltrue`
53+
+ 当你排除 `node_modules` 不通过babel-loader运行时,babel-minify优化不会应用于被排除的文件,因为它们不会通过minifier。
54+
+ 当您使用带有webpack的babel-loader时,由webpack为模块系统生成的代码不会通过loader,并且不会通过babel-minify进行优化。
55+
+ 一个webpack插件可以在整个chunk / bundle输出上运行,并且可以优化整个bundle,你可以看到一些细微的输出差异。但是,由于文件大小通常非常大,所以会慢很多。所以这里有[一个想法](https://github.com/webpack-contrib/babel-minify-webpack-plugin/issues/8)——我们可以将一些优化作为loader的一部分,并在插件中进行一些优化。
5656

57-
## Maintainers
57+
## 维护人员
5858

5959
<table>
6060
<tbody>

0 commit comments

Comments
 (0)