Skip to content

Commit 2ba3eaa

Browse files
committed
update document
1 parent 155a637 commit 2ba3eaa

File tree

7 files changed

+27
-88
lines changed

7 files changed

+27
-88
lines changed

antwar.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = {
7272
),
7373

7474
development: section(
75-
'Development',
75+
'开发',
7676
function() {
7777
return require.context(
7878
'json-loader!yaml-frontmatter-loader!./content/development',

content/concepts/loaders.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,16 @@ contributors:
1111

1212
loader 是对应用程序中资源文件进行转换。它们是(运行在 Node.js 中的)函数,可以将资源文件作为参数的来源,然后返回新的资源文件。
1313

14-
<<<<<<< HEAD
15-
例如,你可以使用 loader 告诉 webpack 加载 CSS 文件,或者将 TypeScript 转为 JavaScript。
16-
=======
17-
## Example
14+
## 示例
1815

19-
For example, you can use loaders to tell webpack to load a CSS file or to convert TypeScript to JavaScript. Firstly, install the corresponding loaders:
16+
例如,你可以使用 loader 告诉 webpack 加载 CSS 文件,或者将 TypeScript 转为 JavaScript。首先,安装相对应的 loader:
2017

2118
```
2219
npm install --save-dev css-loader
2320
npm install --save-dev ts-loader
2421
```
2522

26-
Secondly, configure in your `webpack.config.js` that for every `.css` file the `css-loader` should be used and analogously for `.ts` files and the `ts-loader`:
23+
其次,配置 `webpack.config.js`,对每个 `.css` 文件使用 `css-loader`,然后类似地,对每个 `.ts` 文件使用 `ts-loader`
2724

2825
**webpack.config.js**
2926

@@ -38,7 +35,7 @@ module.exports = {
3835
};
3936
```
4037

41-
Note that according to the [configuration options](/configuration#options), the following specifications define the identical loader usage:
38+
注意,根据[配置选项](/configuration#options),下面的规范定义了同等的 loader 用法:
4239

4340
```js-with-links-with-details
4441
{test: /\.css$/, [loader](/configuration/module#rule-loader): 'css-loader'}
@@ -50,14 +47,13 @@ Note that according to the [configuration options](/configuration#options), the
5047
options: {}
5148
}}
5249
```
53-
>>>>>>> master
5450

5551
## Loader 特性
5652

5753
* loader 支持链式传递。能够对资源使用流水线( pipeline)。loader 链式按照时间先后顺序进行编译。loader 链中的第一个 loader 返回值给下一个 loader。在最后一个 loader,webpack 按照预期的 JavaScript 返回。
5854
* loader 可以是同步或异步函数。
5955
* loader 运行在 Node.js 中,并且能够执行任何可能的操作。
60-
* loader 接受查询参数。用于 loader 间传递配置。
56+
* loader 接收查询参数。用于 loader 间传递配置。
6157
* loader 也能够使用 `options` 对象进行配置。
6258
* 除了直接使用 `package.json``main` 属性,还可以将普通的 npm 模块导出为 loader,做法是在 `package.json` 里定义一个 loader 字段。
6359
* 插件可以给 loader 带来更多功能。
@@ -67,15 +63,9 @@ loader 通过(loader)预处理函数,为 JavaScript 生态系统提供了更
6763

6864
## 解析 Loader
6965

70-
<<<<<<< HEAD
71-
loader [解析类似于模块](/concepts/module-resolution/)。loader 模块需要导出一个函数,并且使用兼容 Node.js 的 JavaScript 编写。在通常情况下,你可以使用 npm 管理 loader,但是你也可以在应用程序中将 loader 作为文件使用。
72-
73-
### 引用 Loader
74-
=======
7566
Loaders follow the standard [module resolution](/concepts/module-resolution/). In most cases you will be loaders from the [module path](/concepts/module-resolution/#module-paths) (think `npm install`, `node_modules`).
7667

7768
[How to write a loader?](/development/how-to-write-a-loader) A loader module is expected to export a function and to be written in Node.js compatible JavaScript. In the common case you manage loaders with npm, but you can also have loaders as files in your app.
78-
>>>>>>> master
7969

8070
按照约定,loader 通常被命名为 `XXX-loader``XXX` 是上下文的名称,例如 `json-loader`
8171

content/configuration/entry-context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ contributors:
77
- tarang9211
88
---
99

10-
The entry object is where webpack looks to start building the bundle. The context is an absolute string to the directory that contains the entry files.
10+
entry 对象是用于 webpack 查找启动并构建 bundle。其上下文是入口文件所处的目录的绝对路径的字符串。
1111

1212
## `context`
1313

content/get-started/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ index.js 1.56 kB 0 [emitted] main
117117

118118
```
119119
T> 输出可能会稍有不同。如果构建成功,那么你就可以继续。
120-
Output may vary. If the build is successful then you are good to go.
121120

122121
T> 如果你在[全局安装 webpack](/get-started/install-webpack#global-installation),你必须使用 `webpack` 来调用 webpack。
123122

content/get-started/install-webpack.md

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,7 @@ sort: 1
1212

1313
注意,本文档适用于 webpack 2,目前还尚未发布 stable 版本。你可以通过在安装时使用 ` beta ` 标签来获取最新beta版本(查看下文)。
1414

15-
<<<<<<< HEAD
16-
### 全局安装
17-
18-
``` bash
19-
npm install webpack@beta -g
20-
```
21-
22-
现在可以在全局使用 `webpack` 命令了。
23-
24-
然而,这并不是推荐用法。这会将你的 webpack 锁定到特定版本,并且可能在使用 webpack 不同版本的项目中失败。接下来的章节向你介绍如何在项目中本地安装 webpack。
25-
=======
26-
The next section tells you how to install webpack locally in a project.
27-
>>>>>>> master
15+
下一章节告诉你如何在本地项目中安装 webpack。
2816

2917
### 本地安装
3018

@@ -47,12 +35,9 @@ npm install webpack@<version> --save-dev
4735
T> 要运行本地安装的 webpack,你可以通过 `node_modules/.bin/webpack` 访问其 bin 版本
4836

4937

50-
<<<<<<< HEAD
51-
### 前沿领域
52-
=======
53-
### Global Installation
38+
### 全局安装
5439

55-
W> Note that a global webpack installation is not a recommended practice. This locks you down to a specific version of webpack and might fail in projects that use a different version.
40+
W> 注意,全局安装 webpack 不是推荐用法。这会将你的 webpack 锁定到特定版本,并且可能在使用 webpack 不同版本的项目中失败。
5641

5742
``` bash
5843
npm install webpack@beta -g
@@ -61,8 +46,7 @@ npm install webpack@beta -g
6146
The `webpack` command is now available globally.
6247

6348

64-
### Bleeding Edge
65-
>>>>>>> master
49+
### 前沿领域
6650

6751
如果你热衷于使用 webpack 提供的最新版本(当心 - 可能不稳定),你可以直接从 webpack 仓库中安装
6852

content/get-started/why-webpack.md

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: 为什么选择 webpack?
33
contributors:
44
- pksjce
55
- bebraw
6+
- chrisVillanueva
67
sort: 2
78
---
89

@@ -29,34 +30,33 @@ T> 尽管 webpack 核心关注于打包,你可以找到各种扩展(extension)
2930

3031
| 特性 | webpack/webpack | jrburke/requirejs | substack/node-browserify | jspm/jspm-cli | rollup/rollup | brunch/brunch |
3132
|---------|-----------------|-------------------|--------------------------|---------------|---------------|---------------|
32-
<<<<<<< HEAD
33-
| 按需加载附加模块 | **yes** | **yes** | no | [System.import](https://github.com/systemjs/systemjs/blob/master/docs/system-api.md#systemimportmodulename--normalizedparentname---promisemodule) | no | no |
34-
| AMD `define` | **yes** | **yes** | [deamdify](https://github.com/jaredhanson/deamdify) | yes | no | yes |
33+
| 附加模块按需加载 | **yes** | **yes** | no | [System.import](https://github.com/systemjs/systemjs/blob/master/docs/system-api.md#systemimportmodulename--normalizedparentname---promisemodule) | no | no |
34+
| AMD `define` | **yes** | **yes** | [deamdify](https://github.com/jaredhanson/deamdify) | yes | [rollup-plugin-amd](https://github.com/brunch/uglify-js-brunch) | yes |
3535
| AMD `require` | **yes** | **yes** | no | yes | no | yes |
3636
| AMD `require` 按需加载 | **yes** | 手动配置 | no | yes | no | no |
3737
| CommonJS `exports` | **yes** | 只包含在 `define`| **yes** | yes | [commonjs-plugin](https://github.com/rollup/rollup-plugin-commonjs) | yes |
3838
| CommonJS `require` | **yes** | 只包含在 `define`| **yes** | yes | [commonjs-plugin](https://github.com/rollup/rollup-plugin-commonjs) | yes |
39-
| CommonJS `require.resolve` | **yes** | no | no | no | no |
40-
| require 中拼接 `require("./fi" + "le")` | **yes** | no♦ | no | no | no |
39+
| CommonJS `require.resolve` | **yes** | no | no | no | no | |
40+
| require 中拼接 `require("./fi" + "le")` | **yes** | no♦ | no | no | no | |
4141
| 调试支持 | **SourceUrl, SourceMaps** | 不需要 | SourceMaps | **SourceUrl, SourceMaps** | **SourceUrl, SourceMaps** | SourceMaps |
42-
| 依赖 | 19MB / 127 个程序包 | 11MB / 118 个程序包 | **1.2MB / 1 个程序包** | 26MB / 131 个程序包 | ?MB / 3 个程序包
43-
| ES2015 `import`/`export` | **yes**(vr. 2) | no | no | **yes****yes** | yes, 通过 [es6 模块转换器](https://github.com/gcollazo/es6-module-transpiler-brunch)
42+
| 依赖 | 19MB / 127 个程序包 | 11MB / 118 个程序包 | **1.2MB / 1 个程序包** | 26MB / 131 个程序包 | ?MB / 3 个程序包 | |
43+
| ES2015 `import`/`export` | **yes** (webpack 2) | no | no | **yes****yes** | yes, 通过 [es6 模块转换器](https://github.com/gcollazo/es6-module-transpiler-brunch)
4444
| require (guided) 中的表达式 `require("./templates/" + template)` | **yes (all files matching included)** | no♦ | no | no | no | no |
45-
| require (free) 中的表达式 `require(moduleName)` | 手动配置 | no♦ | no | no | no |
45+
| require (free) 中的表达式 `require(moduleName)` | 手动配置 | no♦ | no | no | no | |
4646
| 生成单独包 | **yes** | yes♦ | yes | yes | yes | yes |
47-
| 间接的 require `var r = require; r("./file")` | **yes** | no♦ | no | no | no |
47+
| 间接的 require `var r = require; r("./file")` | **yes** | no♦ | no | no | no | |
4848
| 分别加载每个文件 | no | yes | no | yes | no | no |
4949
| 损坏的路径名 | **yes** | no | 部分 | yes | 不需要(路径名称不在包中) | no |
5050
| 压缩 | uglify | uglify, closure compiler | [uglifyify](https://github.com/hughsk/uglifyify) | yes | [uglify-plugin](https://github.com/TrySound/rollup-plugin-uglify) | [UglifyJS-brunch](https://github.com/brunch/uglify-js-brunch)
5151
| 用 common bundle 构建多页 | 手动配置 | **yes** | 手动配置 | 使用包算法 | no | no|
5252
| 多个 bundle | **yes** | 手动配置 | 手动配置 | yes | no | yes |
53-
| Node.js 内置 libs `require("path")` | **yes** | no | **yes** | **yes** | [node-resolve-plugin](https://github.com/rollup/rollup-plugin-node-resolve)
54-
| Node.js 其他 | process, __dir/filename, global | - | process, __dir/filename, global | process, __dir/filename, global for cjs | global ([commonjs-plugin](https://github.com/rollup/rollup-plugin-commonjs)) |
53+
| Node.js 内置 libs `require("path")` | **yes** | no | **yes** | **yes** | [node-resolve-plugin](https://github.com/rollup/rollup-plugin-node-resolve) | |
54+
| Node.js 其他 | process, __dir/filename, global | - | process, __dir/filename, global | process, __dir/filename, global for cjs | global ([commonjs-plugin](https://github.com/rollup/rollup-plugin-commonjs)) | |
5555
| 插件 | **yes** | yes | **yes** | yes | yes | yes |
5656
| 预处理 | **loaders, [transforms](https://github.com/webpack/transform-loader)** | loaders | transforms | plugin translate | plugin transforms | compilers, optimizers |
57-
| 浏览器替换 | `web_modules`, `.web.js`, package.json field, alias config option | alias option | package.json field, alias option | package.json, alias option | no |
57+
| 浏览器替换 | `web_modules`, `.web.js`, package.json field, alias config option | alias option | package.json field, alias option | package.json, alias option | no | |
5858
| 可 require 文件 | 文件系统 | **web** | 文件系统 | 通过插件 | 文件系统或通过插件 | 文件系统 |
59-
| 运行时开销 | **243B + 20B 每个模块 + 4B 每个依赖** | 14.7kB + 0B 每个模块 + (3B + X) 每个依赖 | 415B + 25B 每个模块 + (6B + 2X) 每个依赖 | 5.5kB for 自执行 bundle, 38kB 全部 loader 和 polyfill, 0 普通模块, 293B CJS, 139B ES2015 System.register before gzip | **none for ES2015 modules**(可能有其他格式)
59+
| 运行时开销 | **243B + 20B 每个模块 + 4B 每个依赖** | 14.7kB + 0B 每个模块 + (3B + X) 每个依赖 | 415B + 25B 每个模块 + (6B + 2X) 每个依赖 | 5.5kB for 自执行 bundle, 38kB 全部 loader 和 polyfill, 0 普通模块, 293B CJS, 139B ES2015 System.register before gzip | **none for ES2015 modules**(可能有其他格式) | |
6060
| 观察模式 | yes | 不需要 | yes | 开发不需要 | no | yes |
6161

6262
♦ 在生产模式(在开发模式中相反)
@@ -65,38 +65,4 @@ X是路径字符串的长度
6565

6666
***
6767

68-
> 原文:https://webpack.js.org/get-started/why-webpack/
69-
=======
70-
| Additional chunks are loaded on demand | **yes** | **yes** | no | [System.import](https://github.com/systemjs/systemjs/blob/master/docs/system-api.md#systemimportmodulename--normalizedparentname---promisemodule) | no | no |
71-
| AMD `define` | **yes** | **yes** | [deamdify](https://github.com/jaredhanson/deamdify) | yes | [rollup-plugin-amd](https://github.com/brunch/uglify-js-brunch) | yes |
72-
| AMD `require` | **yes** | **yes** | no | yes | no | yes |
73-
| AMD `require` loads on demand | **yes** | with manual configuration | no | yes | no | no |
74-
| CommonJS `exports` | **yes** | only wrapping in `define` | **yes** | yes | [commonjs-plugin](https://github.com/rollup/rollup-plugin-commonjs) | yes |
75-
| CommonJS `require` | **yes** | only wrapping in `define` | **yes** | yes | [commonjs-plugin](https://github.com/rollup/rollup-plugin-commonjs) | yes |
76-
| CommonJS `require.resolve` | **yes** | no | no | no | no | |
77-
| Concat in require `require("./fi" + "le")` | **yes** | no♦ | no | no | no | |
78-
| Debugging support | **SourceUrl, SourceMaps** | not required | SourceMaps | **SourceUrl, SourceMaps** | **SourceUrl, SourceMaps** | SourceMaps |
79-
| Dependencies | 19MB / 127 packages | 11MB / 118 packages | **1.2MB / 1 package** | 26MB / 131 packages | ?MB / 3 packages | |
80-
| ES2015 `import`/`export` | **yes** (webpack 2) | no | no | **yes****yes** | yes, via [es6 module transpiler](https://github.com/gcollazo/es6-module-transpiler-brunch)
81-
| Expressions in require (guided) `require("./templates/" + template)` | **yes (all files matching included)** | no♦ | no | no | no | no |
82-
| Expressions in require (free) `require(moduleName)` | with manual configuration | no♦ | no | no | no | |
83-
| Generate a single bundle | **yes** | yes♦ | yes | yes | yes | yes |
84-
| Indirect require `var r = require; r("./file")` | **yes** | no♦ | no | no | no | |
85-
| Load each file separate | no | yes | no | yes | no | no |
86-
| Mangle path names | **yes** | no | partial | yes | not required (path names are not included in the bundle) | no |
87-
| Minimizing | uglify | uglify, closure compiler | [uglifyify](https://github.com/hughsk/uglifyify) | yes | [uglify-plugin](https://github.com/TrySound/rollup-plugin-uglify) | [UglifyJS-brunch](https://github.com/brunch/uglify-js-brunch)
88-
| Multi pages build with common bundle | with manual configuration | **yes** | with manual configuration | with bundle arithmetic | no | no|
89-
| Multiple bundles | **yes** | with manual configuration | with manual configuration | yes | no | yes |
90-
| Node.js built-in libs `require("path")` | **yes** | no | **yes** | **yes** | [node-resolve-plugin](https://github.com/rollup/rollup-plugin-node-resolve) | |
91-
| Other Node.js stuff | process, __dir/filename, global | - | process, __dir/filename, global | process, __dir/filename, global for cjs | global ([commonjs-plugin](https://github.com/rollup/rollup-plugin-commonjs)) | |
92-
| Plugins | **yes** | yes | **yes** | yes | yes | yes |
93-
| Preprocessing | **loaders, [transforms](https://github.com/webpack/transform-loader)** | loaders | transforms | plugin translate | plugin transforms | compilers, optimizers |
94-
| Replacement for browser | `web_modules`, `.web.js`, package.json field, alias config option | alias option | package.json field, alias option | package.json, alias option | no | |
95-
| Requirable files | file system | **web** | file system | through plugins | file system or through plugins | file system |
96-
| Runtime overhead | **243B + 20B per module + 4B per dependency** | 14.7kB + 0B per module + (3B + X) per dependency | 415B + 25B per module + (6B + 2X) per dependency | 5.5kB for self-executing bundles, 38kB for full loader and polyfill, 0 plain modules, 293B CJS, 139B ES2015 System.register before gzip | **none for ES2015 modules** (other formats may have) | |
97-
| Watch mode | yes | not required | yes | not needed in dev | no | yes |
98-
99-
♦ in production mode (opposite in development mode)
100-
101-
X is the length of the path string
102-
>>>>>>> master
68+
> 原文:https://webpack.js.org/get-started/why-webpack/

content/guides/public-path.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ contributors:
66
- chrisVillanueva
77
---
88

9-
webpack提供一个非常有用的配置,该配置能帮助你为项目中的所有资源指定一个基础路径。它被称为`公共路径(publicPath)`
9+
webpack 提供一个非常有用的配置,该配置能帮助你为项目中的所有资源指定一个基础路径。它被称为`公共路径(publicPath)`
1010

1111
## 示例
1212

@@ -42,7 +42,7 @@ export default {
4242

4343
### 临时设定路径值
4444

45-
另一个可能出现的情况是,我们需要临时设置公共路径。webpack提供一个全局变量供你设置,它名叫
45+
另一个可能出现的情况是,我们需要临时设置公共路径。webpack 提供一个全局变量供你设置,它名叫
4646
`__webpack_public_path__`。所以在你的项目入口,你可以简单地设置如下:
4747

4848
```js

0 commit comments

Comments
 (0)