-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs(cn): translate src/content/api/loaders.md #755
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
Conversation
Deploy preview for cn-webpack ready! Built with commit c13edee |
这个怎么closed了 |
之前没添加Reviewers,找了一圈没有找到怎么添加,直接Reopen吧 |
|
||
T> Loaders may be added inline in requests and disabled via inline prefixes, which will impact the order in which they are "pitched" and executed. See [`Rule.enforce`](/configuration/module/#ruleenforce) for more details. | ||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是复制多了,还是删少了...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是一不小心加进来的
认真核对下中英文,建议查看 Files Change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请尽快修改
@Aastasia 请尽快修改 |
在翻译的时候,建议恢复 `xxx` 左右的 ` 符号,这是 markdown 提供的高亮颜色 |
|
||
``` diff | ||
|- a-loader `pitch` | ||
|- b-loader `pitch` returns a module | ||
|- a-loader normal execution | ||
``` | ||
|
||
See the [bundle-loader](https://github.com/webpack-contrib/bundle-loader) for a good example of how this process can be used in a more meaningful way. | ||
查看 [bundle-loader](https://github.com/webpack-contrib/bundle-loader) 了解如何以更有意义的方式使用此过程。 | ||
|
||
|
||
## The Loader Context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Loader Context 改为 loader context
|
||
Given the following example, this require call is used: | ||
下面提供一个例子,将使用 require 进行调用: | ||
|
||
In `/abc/file.js`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In /abc/file.js
:
在 /abc/file.js
中:
|
||
在我们的例子中:因为 resource.js 在这个目录中,这个属性为 /abc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
严格点应该说:这个属性的值为 /abc
|
||
T> Since webpack 5, `this.getOptions` is available in loader context. It substitutes `getOptions` method from [loader-utils](https://github.com/webpack/loader-utils#getoptions). | ||
|
||
提取给定的 loader 选项,接受一个可选的 JSON 格式化对象作为参数 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON schema 不需要翻译
@@ -282,6 +273,7 @@ loaders = [{request: string, path: string, query: string, module: function}] | |||
``` | |||
|
|||
In the example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这行应该删除
@@ -649,8 +626,8 @@ module.exports = function(source) { | |||
|
|||
## Logging | |||
|
|||
Logging API is available since the release of webpack 4.37. When `logging` is enabled in [`stats configuration`](/configuration/stats/#statslogging) and/or when [`infrastructure logging`](/configuration/other-options/#infrastructurelogging) is enabled, loaders may log messages which will be printed out in the respective logger format (stats, infrastructure). | |||
自webpack 4.37发布以来,日志API就可用了。当 [`stats configuration`](/configuration/stats/#statslogging) 或者 [`infrastructure logging`](/configuration/other-options/#infrastructurelogging) 开启 logging 时,加载程序可以记录消息,这些消息将以相应的日志格式(stats,infrastructure)打印出来。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加载程序 => loader
- Loaders should prefer to use `this.getLogger()` for logging which is a shortcut to `compilation.getLogger()` with loader path and processed file. This kind of logging is stored to the Stats and formatted accordingly. It can be filtered and exported by the webpack user. | ||
- Loaders may use `this.getLogger('name')` to get an independent logger with a child name. Loader path and processed file is still added. | ||
- Loaders may use special fallback logic for detecting logging support `this.getLogger() ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method. | ||
- Loaders 最好使用 this.getLogger() 用于日志记录,这是指向 compilation.getLogger() 具有加载程序路径和已处理的文件。这种日志记录被存储到Stats中并相应地格式化。它可以被webpack用户过滤和导出。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加载程序 => loader
- Loaders may use `this.getLogger('name')` to get an independent logger with a child name. Loader path and processed file is still added. | ||
- Loaders may use special fallback logic for detecting logging support `this.getLogger() ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method. | ||
- Loaders 最好使用 this.getLogger() 用于日志记录,这是指向 compilation.getLogger() 具有加载程序路径和已处理的文件。这种日志记录被存储到Stats中并相应地格式化。它可以被webpack用户过滤和导出。 | ||
- Loaders 可以使用 this.getLogger("name") 获取具有子名称的独立记录器。仍会添加加载程序路径和已处理的文件。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加载程序 => loader
- Loaders may use `this.getLogger('name')` to get an independent logger with a child name. Loader path and processed file is still added. | ||
- Loaders may use special fallback logic for detecting logging support `this.getLogger() ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method. | ||
- Loaders 最好使用 this.getLogger() 用于日志记录,这是指向 compilation.getLogger() 具有加载程序路径和已处理的文件。这种日志记录被存储到Stats中并相应地格式化。它可以被webpack用户过滤和导出。 | ||
- Loaders 可以使用 this.getLogger("name") 获取具有子名称的独立记录器。仍会添加加载程序路径和已处理的文件。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
记录器 => logger
- Loaders may use special fallback logic for detecting logging support `this.getLogger() ? this.getLogger() : console` to provide a fallback when an older webpack version is used which does not support `getLogger` method. | ||
- Loaders 最好使用 this.getLogger() 用于日志记录,这是指向 compilation.getLogger() 具有加载程序路径和已处理的文件。这种日志记录被存储到Stats中并相应地格式化。它可以被webpack用户过滤和导出。 | ||
- Loaders 可以使用 this.getLogger("name") 获取具有子名称的独立记录器。仍会添加加载程序路径和已处理的文件。 | ||
- Loaders 可以使用特殊的回退逻辑来检测日志支持 this.getLogger() ? this.getLogger() : console。 在使用不支持 getLogger 方法的旧webpack版本时提供回退选项。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
提供回退选项 => 提供回退方法
翻译 API/Loader Interface 部分文档
@QC-L @dear-lizhihua @yuqingc