Skip to content

Commit

Permalink
docs: fix the reference of process assets stages
Browse files Browse the repository at this point in the history
  • Loading branch information
xbzhang2020 committed Feb 27, 2025
1 parent 2d10e9a commit 19c8ad8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions website/docs/en/api/plugin-api/compilation-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,11 @@ Process the assets before emit.

```js
compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {
const { Compilation } = compiler.webpack;
compilation.hooks.processAssets.tap(
{
name: 'MyPlugin',
stage: compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
},
assets => {
const { RawSource } = compiler.webpack.sources;
Expand All @@ -743,10 +744,11 @@ compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {

```js
compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {
const { Compilation } = compiler.webpack;
compilation.hooks.processAssets.tap(
{
name: 'MyPlugin',
stage: compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
},
assets => {
const asset = assets['foo.js'];
Expand All @@ -769,10 +771,11 @@ compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {

```js
compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {
const { Compilation } = compiler.webpack;
compilation.hooks.processAssets.tap(
{
name: 'MyPlugin',
stage: compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
},
assets => {
const assetName = 'unwanted-script.js';
Expand Down
9 changes: 6 additions & 3 deletions website/docs/zh/api/plugin-api/compilation-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,11 @@ console.log(__webpack_require__.p);

```js
compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {
const { Compilation } = compiler.webpack;
compilation.hooks.processAssets.tap(
{
name: 'MyPlugin',
stage: compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
},
assets => {
const { RawSource } = compiler.webpack.sources;
Expand All @@ -745,10 +746,11 @@ compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {

```js
compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {
const { Compilation } = compiler.webpack;
compilation.hooks.processAssets.tap(
{
name: 'MyPlugin',
stage: compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
},
assets => {
const asset = assets['foo.js'];
Expand All @@ -771,10 +773,11 @@ compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {

```js
compiler.hooks.thisCompilation.tap('MyPlugin', compilation => {
const { Compilation } = compiler.webpack;
compilation.hooks.processAssets.tap(
{
name: 'MyPlugin',
stage: compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
},
assets => {
const assetName = 'unwanted-script.js';
Expand Down

0 comments on commit 19c8ad8

Please sign in to comment.