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 @ bde990a7 #1696

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
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
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
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"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"
},
Expand All @@ -83,19 +83,19 @@
"@octokit/rest": "^19.0.4",
"@pmmmwh/react-refresh-webpack-plugin": "next",
"@svgr/webpack": "^6.3.1",
"autoprefixer": "^10.4.11",
"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",
"cypress": "^10.8.0",
"directory-tree": "^3.3.1",
"directory-tree-webpack-plugin": "^1.0.3",
"duplexer": "^0.1.1",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-mdx": "^2.0.4",
"eslint-plugin-mdx": "^2.0.5",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"front-matter": "^4.0.2",
Expand All @@ -106,7 +106,7 @@
"husky": "^8.0.1",
"hyperlink": "^5.0.4",
"jest": "^29.0.3",
"lightningcss": "^1.15.1",
"lightningcss": "^1.16.0",
"lint-staged": "^13.0.3",
"lodash": "^4.17.21",
"markdownlint": "^0.26.2",
Expand All @@ -131,7 +131,7 @@
"remark-html": "^15.0.1",
"remark-refractor": "montogeek/remark-refractor",
"rimraf": "^3.0.2",
"sass": "^1.54.9",
"sass": "^1.55.0",
"sass-loader": "^13.0.2",
"sirv-cli": "^2.0.2",
"sitemap-static": "^0.4.2",
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,7 +157,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet-async": "^1.3.0",
"react-router-dom": "^6.4.0",
"react-router-dom": "^6.4.1",
"react-spring": "^9.5.4",
"react-tiny-popover": "5",
"react-use": "^17.4.0",
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
>>>>>>> bde990a7603dba2eb4d0e04e9c67dea8f5702e0a

- `logger.error(...)`:用于输出错误信息
- `logger.warn(...)`:用于输出警告信息
Expand Down
7 changes: 5 additions & 2 deletions src/content/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ contributors:
- bigdawggi
- anshumanv
- textbook
<<<<<<< HEAD
translators:
- dear-lizhihua
- QC-L
=======
- coly010
>>>>>>> bde990a7603dba2eb4d0e04e9c67dea8f5702e0a
---

webpack 开箱即用,可以无需使用任何配置文件。然而,webpack 会假定项目的入口起点为 `src/index.js`,然后会在 `dist/main.js` 输出结果,并且在生产环境开启压缩和优化。
Expand Down Expand Up @@ -59,6 +63,7 @@ W> Notice that many array configurations allow to reference the default value vi
const path = require('path');

module.exports = {
name: "my-config", // name of the configuration, shown in output
<mode "/configuration/mode">
<default>
mode: "production", // "production" | "development" | "none"
Expand Down Expand Up @@ -181,8 +186,6 @@ module.exports = {
},
uniqueName: "my-application", // (defaults to package.json "name")
// unique name for this build to avoid conflicts with other builds in the same HTML
name: "my-config",
// name of the configuration, shown in output
<advancedOutput "#">
<default>
/* 高级输出配置(点击显示) */
Expand Down
8 changes: 8 additions & 0 deletions src/content/configuration/watch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ contributors:
- Neob91
- Loonride
- snitin315
<<<<<<< HEAD
translators:
- lcxfs1991
- QC-L
- jacob-lcs
=======
- chenxsan
>>>>>>> bde990a7603dba2eb4d0e04e9c67dea8f5702e0a
---

Webpack 可以监听文件变化,当它们修改后会重新编译。这个页面介绍了如何启用这个功能,以及当 watch 无法正常运行的时候你可以做的一些调整。
Expand Down Expand Up @@ -132,7 +136,11 @@ T> 如果你使用 `require.context`,webpack 会监听你的整个目录。你

`boolean = false` `number`

<<<<<<< HEAD
通过传递 `true` 开启 [polling](https://whatis.techtarget.com/definition/polling),或者指定毫秒为单位进行轮询。
=======
Turn on [polling](<https://en.wikipedia.org/wiki/Polling_(computer_science)>) by passing `true` which would set the default poll interval to [`5007`](https://github.com/webpack/watchpack/blob/a54bcdb95759558ca5a9fc2819c4d71b771c162f/lib/DirectoryWatcher.js#L79), or specifying a poll interval in milliseconds:
>>>>>>> bde990a7603dba2eb4d0e04e9c67dea8f5702e0a

**webpack.config.js**

Expand Down
21 changes: 21 additions & 0 deletions src/content/guides/asset-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,24 @@ module: {
]
},
```

## Disable emitting assets

For use cases like Server side rendering, you might want to disable emitting assets, which is feasible with [`emit`](/configuration/module/#rulegeneratoremit) option under `Rule.generator`:

```js
module.exports = {
// …
module: {
rules: [
{
test: /\.png$/i,
type: 'asset/resource',
generator: {
emit: false,
},
},
],
},
};
```
Loading