Skip to content

Commit e78d7da

Browse files
committed
/content/configuration/devtool.md
1 parent 712f7ab commit e78d7da

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

content/configuration/devtool.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,59 @@ contributors:
77
- SpaceK33z
88
---
99

10-
This option controls if and how Source Maps are generated.
10+
此选项控制是否生成,以及如何生成 Source Map。
1111

1212
## `devtool`
1313

1414
`string` `false`
1515

16-
选择一种[源映射(source mapping)](http://blog.teamtreehouse.com/introduction-source-maps)来增强调试过程。注意,以下选项能够可能会显著地影响构建(build)和重构建(rebuild)的速度……
16+
选择一种 [source map](http://blog.teamtreehouse.com/introduction-source-maps) 来增强调试过程。注意,以下选项能够可能会很明显地影响构建(build)和重构建(rebuild)的速度
1717

18-
devtool | build | rebuild | production | quality
18+
devtool | 构建 | 重构建 | 生产环境 | 特性
1919
------------------------------|-------|---------|------------|--------------------------
20-
eval | +++ | +++ | no | 生成代码
21-
cheap-eval-source-map | + | ++ | no | 转换后代码(仅限行)
22-
cheap-source-map | + | o | yes | 转换后代码(仅限行)
20+
eval | +++ | +++ | no | 生成后的代码
21+
cheap-eval-source-map | + | ++ | no | 转换过的代码(仅限行)
22+
cheap-source-map | + | o | yes | 转换过的代码(仅限行)
2323
cheap-module-eval-source-map | o | ++ | no | 原始源码(仅限行)
2424
cheap-module-source-map | o | - | yes | 原始源码(仅限行)
2525
eval-source-map | -- | + | no | 原始源码
2626
source-map | -- | -- | yes | 原始源码
27-
nosources-source-map | -- | -- | yes | 无源码内容
27+
nosources-source-map | -- | -- | yes | 无源码内容
2828

29-
Some of these values are suited for development and some for production. For development you typically want fast Source Maps at the cost of bundle size, but for production you want separate Source Maps that are accurate.
29+
其中一些值适用于开发环境,一些适用于生产环境。对于开发环境,通常希望更快速的 Source Map,需要添加到 bundle 中以增加体积为代价,但是对于生产环境,则希望更精准的 Source Map,需要从 bundle 中分离并独立存在。
3030

31-
W> There are some issues with Source Maps in Chrome. [We need your help!](https://github.com/webpack/webpack/issues/3165).
31+
W> Chrome 中的 Source Map 有一些问题。[我们需要你的帮助!](https://github.com/webpack/webpack/issues/3165)
3232

33-
### For development
33+
### 对于开发环境
3434

35-
`eval` - Each module is executed with `eval()` and `//@ sourceURL`. This is pretty fast. The main disadvantage is that it doesn't display line numbers correctly since it gets mapped to transpiled code instead of the original code.
35+
`eval` - 每个模块都使用 `eval()` 执行,并且都有 `//@ sourceURL`。此选项会相当快地构建。主要缺点是,由于会映射到转换后的代码,而不是映射到原始代码,所以不能正确的显示显示行数。
3636

37-
`inline-source-map` - A SourceMap is added as a DataUrl to the bundle.
37+
`inline-source-map` - SourceMap 转换为 DataUrl 后添加到 bundle 中。
3838

39-
`eval-source-map` - Each module is executed with `eval()` and a SourceMap is added as a DataUrl to the `eval()`. Initially it is slow, but it provides fast rebuild speed and yields real files. Line numbers are correctly mapped since it gets mapped to the original code.
39+
`eval-source-map` - 每个模块使用 `eval()` 执行,并且 SourceMap 转换为 DataUrl 后添加到 `eval()` 中。初始化 SourceMap 时比较慢,但是会在重构建时提供很快的速度,并且生成实际的文件。行数能够正确映射,因为会映射到原始代码中。
4040

41-
`cheap-module-eval-source-map` - Like `eval-source-map`, each module is executed with `eval()` and a SourceMap is added as a DataUrl to the `eval()`. It is "cheap" because it doesn't have column mappings, it only maps line numbers.
41+
`cheap-module-eval-source-map` - 就像 `eval-source-map`,每个模块使用 `eval()` 执行,并且 SourceMap 转换为 DataUrl 后添加到 `eval()` 中。"低开销"是因为它没有生成列映射(column map),只是映射行数。
4242

43-
### For production
43+
### 对于生产环境
4444

45-
`source-map` - A full SourceMap is emitted as a separate file. It adds a reference comment to the bundle so development tools know where to find it.
45+
`source-map` - 生成完整的 SourceMap,输出为独立文件。由于在 bundle 中添加了引用注释,所以开发工具知道在哪里去找到 SourceMap。
4646

47-
`hidden-source-map` - Same as `source-map`, but doesn't add a reference comment to the bundle. Useful if you only want SourceMaps to map error stack traces from error reports, but don't want to expose your SourceMap for the browser development tools.
47+
`hidden-source-map` - `source-map` 相同,但是没有在 bundle 中添加引用注释。如果你只想要 SourceMap 映射错误报告中的错误堆栈跟踪信息,但不希望将 SourceMap 暴露给浏览器开发工具。
4848

49-
`cheap-source-map` - A SourceMap without column-mappings ignoring loaded Source Maps.
49+
`cheap-source-map` - 不带列映射(column-map)的 SourceMap,忽略加载的 Source Map。
5050

51-
`cheap-module-source-map` - A SourceMap without column-mappings that simplifies loaded Source Maps to a single mapping per line.
51+
`cheap-module-source-map` - 不带列映射(column-map)的 SourceMap,将加载的 Source Map 简化为每行单独映射。
5252

53-
`nosources-source-map` - A SourceMap is created without the `sourcesContent` in it. It can be used to map stack traces on the client without exposing all of the source code.
53+
`nosources-source-map` - 创建一个没有 `sourcesContent` 的 SourceMap。它可以用来映射客户端(译者注:指浏览器)上的堆栈跟踪,而不会暴露所有的源码。
5454

55-
T> See [`output.sourceMapFilename`](/configuration/output#output-sourcemapfilename) to customize the filenames of generated Source Maps.
55+
T> 查看 [`output.sourceMapFilename`](/configuration/output#output-sourcemapfilename) 自定义生成的 Source Map 的文件名。
5656

5757
?> This page needs more information to make it easier for users to choose a good option.
5858

59-
# References
59+
# 参考
6060

61-
- [Enabling Sourcemaps](http://survivejs.com/webpack/developing-with-webpack/enabling-sourcemaps/)
62-
- [webpack devtool source map](http://cheng.logdown.com/posts/2016/03/25/679045
63-
)
61+
- [Enabling Sourcemaps(启用 Sourcemap)](http://survivejs.com/webpack/developing-with-webpack/enabling-sourcemaps/)
62+
- [webpack devtool source map(webpack 开发工具中 source map 的一些验证和结论)](http://cheng.logdown.com/posts/2016/03/25/679045)
6463

6564
***
6665

0 commit comments

Comments
 (0)