Skip to content

docs(cn): translate src/content/plugins/banner-plugin.mdx #1280

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

Merged
merged 1 commit into from
Aug 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/content/plugins/banner-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,50 @@ related:
url: https://github.com/webpack/webpack/blob/master/test/configCases/plugins/banner-plugin-hashing/webpack.config.js
---

Adds a banner to the top of each generated chunk.
为每个 chunk 文件头部添加 banner。

```javascript
const webpack = require('webpack');

new webpack.BannerPlugin(banner);
// or
// 或者
new webpack.BannerPlugin(options);
```

## Options $#options$
## 选项 $#options$

```ts
{
banner: string | function, // the banner as string or function, it will be wrapped in a comment
raw: boolean, // if true, banner will not be wrapped in a comment
entryOnly: boolean, // if true, the banner will only be added to the entry chunks
test: string | RegExp | [string, RegExp], // Include all modules that pass test assertion.
include: string | RegExp | [string, RegExp], // Include all modules matching any of these conditions.
exclude: string | RegExp | [string, RegExp], // Exclude all modules matching any of these conditions.
banner: string | function, // 其值为字符串或函数,将作为注释存在
raw: boolean, // 如果值为 true,将直接输出,不会被作为注释
entryOnly: boolean, // 如果值为 true,将只在入口 chunks 文件中添加
test: string | RegExp | [string, RegExp], // 包含所有匹配的模块
include: string | RegExp | [string, RegExp], // 根据条件匹配所有模块
exclude: string | RegExp | [string, RegExp], // 根据条件排除所有模块
}
```

## Usage $#usage$
## 用法 $#usage$

```javascript
import webpack from 'webpack';

// string
// 字符串
new webpack.BannerPlugin({
banner: 'hello world',
});

// function
// 函数
new webpack.BannerPlugin({
banner: (yourVariable) => {
return `yourVariable: ${yourVariable}`;
},
});
```

## Placeholders $#placeholders$
## 占位符 $#placeholders$

Since webpack 2.5.0, placeholders are evaluated in the `banner` string:
webpack 2.5.0 开始,会对 `banner` 字符串中的占位符取值:

```javascript
import webpack from 'webpack';
Expand Down