Skip to content
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

docs(en): merge webpack.js.org/master into webpack.js.org/cn @ 12b725a7 #1711

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c88ec92
docs(configuration): move `name` option to correct place (#6407)
Coly010 Sep 20, 2022
a82ed1b
build(deps-dev): bump webpack-dev-server from 4.11.0 to 4.11.1 (#6409)
dependabot[bot] Sep 20, 2022
3b68bd6
build(deps-dev): bump eslint-plugin-mdx from 2.0.4 to 2.0.5 (#6410)
dependabot[bot] Sep 20, 2022
7c2cc4e
docs(guides): add emit section for asset modules (#6411)
chenxsan Sep 21, 2022
a061579
build(deps-dev): bump lightningcss from 1.15.1 to 1.16.0 (#6412)
dependabot[bot] Sep 21, 2022
1d43859
docs(api): improve logging api (#6413)
chenxsan Sep 21, 2022
9060a92
build(deps-dev): bump autoprefixer from 10.4.11 to 10.4.12 (#6414)
dependabot[bot] Sep 22, 2022
0ccd06c
build(deps-dev): bump sass from 1.54.9 to 1.55.0 (#6416)
dependabot[bot] Sep 23, 2022
97e2ef2
build(deps): bump react-router-dom from 6.4.0 to 6.4.1 (#6417)
dependabot[bot] Sep 23, 2022
10fd714
CI: running e2e tests with Chrome (#6415)
chenxsan Sep 23, 2022
bde990a
docs(configuration): mention default watchOptions.poll value (#6419)
chenxsan Sep 26, 2022
bbdd8bb
build(deps-dev): bump eslint from 8.23.1 to 8.24.0 (#6420)
dependabot[bot] Sep 27, 2022
f10a990
build(deps): bump react-spring from 9.5.4 to 9.5.5 (#6421)
dependabot[bot] Sep 27, 2022
af245f8
build(deps-dev): bump cypress from 10.8.0 to 10.9.0 (#6423)
dependabot[bot] Sep 28, 2022
9d46f0e
build(deps-dev): bump @babel/preset-env from 7.19.1 to 7.19.3 (#6424)
dependabot[bot] Sep 28, 2022
f71118f
build(deps-dev): bump @babel/core from 7.19.1 to 7.19.3 (#6425)
dependabot[bot] Sep 28, 2022
99724ef
build(deps-dev): bump css-minimizer-webpack-plugin from 4.1.0 to 4.2.…
dependabot[bot] Oct 1, 2022
e729946
build(deps-dev): bump jest from 29.0.3 to 29.1.2 (#6428)
dependabot[bot] Oct 1, 2022
d862d15
build(deps-dev): bump postcss from 8.4.16 to 8.4.17 (#6429)
dependabot[bot] Oct 1, 2022
7a820ae
build(deps-dev): bump @svgr/webpack from 6.3.1 to 6.4.0 (#6431)
dependabot[bot] Oct 4, 2022
6e78169
build(deps): bump react-router-dom from 6.4.1 to 6.4.2 (#6432)
dependabot[bot] Oct 7, 2022
39f5e66
build(deps-dev): bump css-minimizer-webpack-plugin from 4.2.0 to 4.2.…
dependabot[bot] Oct 7, 2022
d6a42c5
build(deps-dev): bump sass-loader from 13.0.2 to 13.1.0 (#6435)
dependabot[bot] Oct 8, 2022
e604104
docs(guides): mention limitation of Worker api (#6436)
chenxsan Oct 9, 2022
df2ab78
fix background color for inline code under dark mode (#6438)
chenxsan Oct 9, 2022
3dab627
CI: cancel previous runs for pull requests (#6437)
chenxsan Oct 10, 2022
0847079
CI: pin cancel workflow action version (#6440)
chenxsan Oct 10, 2022
3124f6c
build(deps-dev): bump @pmmmwh/react-refresh-webpack-plugin (#6442)
dependabot[bot] Oct 11, 2022
e902e27
build(deps-dev): bump @babel/preset-env from 7.19.3 to 7.19.4 (#6445)
dependabot[bot] Oct 11, 2022
e627888
build(deps-dev): bump eslint-plugin-react from 7.31.8 to 7.31.9 (#6443)
dependabot[bot] Oct 11, 2022
1028ce0
build(deps-dev): bump eslint from 8.24.0 to 8.25.0 (#6444)
dependabot[bot] Oct 11, 2022
98f254c
docs(configuration): update configuration page (#6441)
chenxsan Oct 11, 2022
86a9696
enable markdownlint for mdx (#6446)
chenxsan Oct 12, 2022
3bc80c4
build(deps-dev): bump eslint-plugin-react from 7.31.9 to 7.31.10 (#6448)
dependabot[bot] Oct 12, 2022
79e7947
build(deps-dev): bump cypress from 10.9.0 to 10.10.0 (#6449)
dependabot[bot] Oct 13, 2022
ff92f61
build(deps-dev): bump css-minimizer-webpack-plugin from 4.2.1 to 4.2.…
dependabot[bot] Oct 14, 2022
dcb3671
docs(configuration): Warn about module output being not usable in web…
jtomaszewski Oct 14, 2022
dce33bc
build(deps-dev): bump @octokit/auth-action from 2.0.1 to 2.0.2 (#6451)
dependabot[bot] Oct 14, 2022
12b725a
build(deps-dev): bump postcss from 8.4.17 to 8.4.18 (#6452)
dependabot[bot] Oct 14, 2022
be720a0
docs(en): merging all conflicts
docschina-bot Oct 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/cancel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Cancel
on:
workflow_run:
workflows: ["Ensure PR"]
types:
- requested
jobs:
cancel:
runs-on: ubuntu-latest
steps:
- uses: styfle/cancel-workflow-action@0.10.1
with:
workflow_id: ${{ github.event.workflow.id }}
1 change: 1 addition & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
- name: Cypress run
uses: cypress-io/github-action@v4
with:
browser: chrome
config-file: cypress.config.js
build: yarn build
start: yarn serve-dist
Expand Down
6 changes: 5 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
"MD002": false,
"MD004": { "style": "dash" },
"MD007": { "indent": 2 },
"MD013": { "line_length": 600 },
"MD013": { "line_length": 600, "code_blocks": false },
"MD024": {
"siblings_only": true
},
"MD026": false,
"MD029": { "style": "ordered" },
"MD033": false,
"MD034": false,
"MD036": false,
"MD041": false,
"MD053": false,
"no-hard-tabs": false,
"whitespace": false
}
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"lint": "run-s lint:*",
"lint:js": "npm run lint-js .",
"lint-js": "eslint --cache --cache-location .cache/.eslintcache",
"lint:markdown": "npm run lint-markdown *.md",
"lint-markdown": "markdownlint --config ./.markdownlint.json --ignore '.vale/**/*.md' --ignore '.github/**/*.md'",
"lint:markdown": "npm run lint-markdown '**/*.{md,mdx}'",
"lint-markdown": "markdownlint --config ./.markdownlint.json",
"lint:prose": "vale --config='.vale.ini' src/content",
"lint:links": "hyperlink -c 8 --root dist -r dist/index.html --canonicalroot https://webpack.js.org/ --internal --skip /plugins/extract-text-webpack-plugin/ --skip /printable --skip https:// --skip http:// --skip sw.js > internal-links.tap; cat internal-links.tap | tap-spot",
"lint:heading": "textlint --fix src/content/*",
Expand All @@ -57,46 +57,46 @@
"printable": "node ./src/scripts/concatenate-docs.mjs",
"jest": "NODE_OPTIONS=--experimental-vm-modules jest --config=jest.config.mjs",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"cypress:run": "cypress run --browser chrome",
"prettier": "prettier --write '**/*.{js,json,jsx,css,scss,md,mdx}'",
"prepare": "husky install && rimraf ./node_modules/.cache/webpack && yarn-deduplicate --strategy fewer"
},
"lint-staged": {
"*.{js,jsx,md,mdx}": [
"npm run lint-js"
],
"*.md": [
"*.{md,mdx}": [
"npm run lint-markdown"
],
"*.{js,jsx,css,scss,md,mdx,json}": [
"prettier --write"
]
},
"devDependencies": {
"@babel/core": "^7.19.1",
"@babel/core": "^7.19.3",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-proposal-class-properties": "^7.17.12",
"@babel/preset-env": "^7.19.1",
"@babel/preset-env": "^7.19.4",
"@babel/preset-react": "^7.18.6",
"@mdx-js/loader": "^2.0.0-next.9",
"@octokit/auth-action": "^2.0.1",
"@octokit/auth-action": "^2.0.2",
"@octokit/rest": "^19.0.4",
"@pmmmwh/react-refresh-webpack-plugin": "next",
"@svgr/webpack": "^6.3.1",
"autoprefixer": "^10.4.11",
"@svgr/webpack": "^6.4.0",
"autoprefixer": "^10.4.12",
"babel-loader": "^8.2.5",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.1",
"css-minimizer-webpack-plugin": "^4.1.0",
"cypress": "^10.7.0",
"css-minimizer-webpack-plugin": "^4.2.2",
"cypress": "^10.10.0",
"directory-tree": "^3.3.1",
"directory-tree-webpack-plugin": "^1.0.3",
"duplexer": "^0.1.1",
"eslint": "^8.23.1",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-mdx": "^2.0.4",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-mdx": "^2.0.5",
"eslint-plugin-react": "^7.31.10",
"eslint-plugin-react-hooks": "^4.6.0",
"front-matter": "^4.0.2",
"github-slugger": "^1.4.0",
Expand All @@ -105,8 +105,8 @@
"http-server": "^14.1.1",
"husky": "^8.0.1",
"hyperlink": "^5.0.4",
"jest": "^29.0.3",
"lightningcss": "^1.15.1",
"jest": "^29.1.2",
"lightningcss": "^1.16.0",
"lint-staged": "^13.0.3",
"lodash": "^4.17.21",
"markdownlint": "^0.26.2",
Expand All @@ -117,7 +117,7 @@
"modularscale-sass": "^3.0.3",
"node-fetch": "^3.2.10",
"npm-run-all": "^4.1.1",
"postcss": "^8.4.16",
"postcss": "^8.4.18",
"postcss-loader": "^7.0.1",
"prettier": "^2.7.1",
"react-refresh": "^0.14.0",
Expand All @@ -131,8 +131,8 @@
"remark-html": "^15.0.1",
"remark-refractor": "montogeek/remark-refractor",
"rimraf": "^3.0.2",
"sass": "^1.54.9",
"sass-loader": "^13.0.2",
"sass": "^1.55.0",
"sass-loader": "^13.1.0",
"sirv-cli": "^2.0.2",
"sitemap-static": "^0.4.2",
"static-site-generator-webpack-plugin": "^3.4.1",
Expand All @@ -145,7 +145,7 @@
"webpack": "^5.74.0",
"webpack-bundle-analyzer": "^4.6.1",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.0",
"webpack-dev-server": "^4.11.1",
"webpack-merge": "^5.8.0",
"workbox-webpack-plugin": "^6.5.4",
"yarn-deduplicate": "^6.0.0"
Expand All @@ -157,8 +157,8 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet-async": "^1.3.0",
"react-router-dom": "^6.4.0",
"react-spring": "^9.5.4",
"react-router-dom": "^6.4.2",
"react-spring": "^9.5.5",
"react-tiny-popover": "5",
"react-use": "^17.4.0",
"react-visibility-sensor": "^5.0.2",
Expand Down
7 changes: 5 additions & 2 deletions src/content/api/loaders.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ module.exports = function (source) {

这个模块将获取像下面的 bundle:

```
```text
/***/ "./src/loader.js!./src/lib.js":
/*!************************************!*\
!*** ./src/loader.js!./src/lib.js ***!
Expand Down Expand Up @@ -725,7 +725,10 @@ module.exports = function (source) {
if (STYLES_REGEXP.test(source)) {
source = source.replace(STYLES_REGEXP, '');
return `import ${JSON.stringify(
this.utils.contextify(this.context || this.rootContext, `${this.resource}.css!=!${getStylesLoader}!${this.remainingRequest}`)
this.utils.contextify(
this.context || this.rootContext,
`${this.resource}.css!=!${getStylesLoader}!${this.remainingRequest}`
)
)};${source}`;
}
return source;
Expand Down
11 changes: 11 additions & 0 deletions src/content/api/logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,18 @@ module.exports = function (source) {
};
```

<<<<<<< HEAD
## Logger methods $#logger-methods$
=======
As you can see from the above `my-webpack-plugin.js` example, there're two types of logging methods,

1. `compilation.getLogger`
2. `compiler.getInfrastructureLogger`

It's advised to use `compilation.getLogger` when plugin/logging is related to the compilation, and they will be stored within the stats. For logging that happens outside the compilation cycle, use `compiler.getInfrastructureLogger` instead.

## Logger methods
>>>>>>> 12b725a787c907043f7c8488dd77f500cba69f3f

- `logger.error(...)`:用于输出错误信息
- `logger.warn(...)`:用于输出警告信息
Expand Down
13 changes: 13 additions & 0 deletions src/content/api/module-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,14 @@ webpack 特定。[`module.hot`](#modulehot-webpack-specific) 的一个别名,[
) => webpack.Context;
```

<<<<<<< HEAD
- 可用版本:5.70.0+
- 示例:
=======
- Available: 5.70.0+
- Example:

>>>>>>> 12b725a787c907043f7c8488dd77f500cba69f3f
```js
const contextRequire = import.meta.webpackContext('.', {
recursive: false,
Expand Down Expand Up @@ -286,9 +292,16 @@ if (__webpack_is_included__('./module-a.js')) {

运行时修改 base 的 URI。

<<<<<<< HEAD
- 类型:`string`
- 可用:5.21.0+
- 示例:
=======
- Type: `string`
- Available: 5.21.0+
- Example:

>>>>>>> 12b725a787c907043f7c8488dd77f500cba69f3f
```js
__webpack_base_uri__ = 'https://example.com';
```
Expand Down
4 changes: 4 additions & 0 deletions src/content/configuration/experiments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ When enabled, webpack can build remote resources that begin with the `http(s):`
A shortcut for [`experiments.buildHttp.allowedUris`](#experimentsbuildhttpalloweduris).

- `HttpUriOptions`

```ts
{
allowedUris: (string|RegExp|(uri: string) => boolean)[],
Expand Down Expand Up @@ -137,6 +138,7 @@ Define the location for caching remote resources.
- `string`
- `false`
- Example

```javascript
// webpack.config.js
module.exports = {
Expand Down Expand Up @@ -262,6 +264,7 @@ Compile entrypoints and dynamic `import`s only when they are in use. It can be u

- Available: 5.17.0+
- Example 1:

```js
module.exports = {
// …
Expand All @@ -270,6 +273,7 @@ Compile entrypoints and dynamic `import`s only when they are in use. It can be u
},
};
```

- Example 2:

```js
Expand Down
69 changes: 47 additions & 22 deletions src/content/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ contributors:
- bigdawggi
- anshumanv
- textbook
<<<<<<< HEAD
translators:
- dear-lizhihua
- QC-L
=======
- coly010
- chenxsan
>>>>>>> 12b725a787c907043f7c8488dd77f500cba69f3f
---

webpack 开箱即用,可以无需使用任何配置文件。然而,webpack 会假定项目的入口起点为 `src/index.js`,然后会在 `dist/main.js` 输出结果,并且在生产环境开启压缩和优化。
Expand All @@ -45,6 +50,7 @@ T> 刚开始学习 webpack?请查看我们提供的指南,从 webpack 一些
}
```

<<<<<<< HEAD
## 选项 $#options$

点击下面配置代码中每个选项的名称,跳转到详细的文档。还要注意,带有箭头的项目可以展开,以显示更多示例,在某些情况下可以看到高级配置。
Expand Down Expand Up @@ -1137,39 +1143,58 @@ module.exports = {
</advancedBuild>
}
```
=======
## Set up a new webpack project
>>>>>>> 12b725a787c907043f7c8488dd77f500cba69f3f

W> 在应用 [插件默认值](/contribute/writing-a-plugin/#configuration-defaults) 之后,webpack 将应用配置默认值。

<<<<<<< HEAD
为了快速生成符合项目要求的 webpack 配置文件,在使用 [webpack-cli 的 `init` 命令](/api/cli/#init)时,会在创建配置文件之前会询问你几个问题。
=======
Webpack has a huge set of options which might be overwhelming to you, please take advantage of [webpack-cli's `init` command](/api/cli/#init) which could rapidly generate webpack configuration files for your project requirements, it will ask you a couple of questions before creating a configuration file.
>>>>>>> 12b725a787c907043f7c8488dd77f500cba69f3f

```bash
npx webpack-cli init
npx webpack init
```

<<<<<<< HEAD
如果尚未在项目或全局安装 `@webpack-cli/init`,npx 可能会提示你安装。根据你在配置生成过程中的选择,你也可能会安装额外的 package 到你的项目中。
=======
npx might prompt you to install `@webpack-cli/generators` if it is not yet installed in the project or globally. You might also get additional packages installed to your project depending on the choices you've made during the configuration generation.
>>>>>>> 12b725a787c907043f7c8488dd77f500cba69f3f

```bash
npx webpack-cli init
$ npx webpack init

ℹ INFO For more information and a detailed description of each question, have a look at https://github.com/webpack/webpack-cli/blob/master/INIT.md
ℹ INFO Alternatively, run `webpack(-cli) --help` for usage info.
[webpack-cli] For using this command you need to install: '@webpack-cli/generators' package.
[webpack-cli] Would you like to install '@webpack-cli/generators' package? (That will run 'npm install -D @webpack-cli/generators') (Y/n)
devDependencies:
+ @webpack-cli/generators 2.5.0
? Which of the following JS solutions do you want to use? ES6
? Do you want to use webpack-dev-server? Yes
? Do you want to simplify the creation of HTML files for your bundle? Yes
? Do you want to add PWA support? No
? Which of the following CSS solutions do you want to use? CSS only
? Will you be using PostCSS in your project? Yes
? Do you want to extract CSS for every file? Only for Production
? Do you like to install prettier to format generated configuration? Yes
? Pick a package manager: pnpm
[webpack-cli] ℹ INFO Initialising project...

? Will your application have multiple bundles? No
? Which module will be the first to enter the application? [default: ./src/index]
? Which folder will your generated bundles be in? [default: dist]:
? Will you be using ES2015? Yes
? Will you use one of the below CSS solutions? No

+ babel-plugin-syntax-dynamic-import@6.18.0
+ uglifyjs-webpack-plugin@2.0.1
+ webpack-cli@3.2.3
+ @babel/core@7.2.2
+ babel-loader@8.0.4
+ @babel/preset-env@7.1.0
+ webpack@4.29.3
added 124 packages from 39 contributors, updated 4 packages and audited 25221 packages in 7.463s
found 0 vulnerabilities


Congratulations! Your new webpack configuration file has been created!
devDependencies:
+ @babel/core 7.19.3
+ @babel/preset-env 7.19.4
+ autoprefixer 10.4.12
+ babel-loader 8.2.5
+ css-loader 6.7.1
+ html-webpack-plugin 5.5.0
+ mini-css-extract-plugin 2.6.1
+ postcss 8.4.17
+ postcss-loader 7.0.1
+ prettier 2.7.1
+ style-loader 3.3.1
+ webpack-dev-server 4.11.1
[webpack-cli] Project has been initialised with webpack!
```