From 19c8ad8ad679672fa33205bdcdd5afaf0ff8247f Mon Sep 17 00:00:00 2001 From: zhangxingbin Date: Thu, 27 Feb 2025 09:29:34 +0800 Subject: [PATCH] docs: fix the reference of process assets stages --- website/docs/en/api/plugin-api/compilation-hooks.mdx | 9 ++++++--- website/docs/zh/api/plugin-api/compilation-hooks.mdx | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/website/docs/en/api/plugin-api/compilation-hooks.mdx b/website/docs/en/api/plugin-api/compilation-hooks.mdx index ed9575d2e53a..9b4f4bd94620 100644 --- a/website/docs/en/api/plugin-api/compilation-hooks.mdx +++ b/website/docs/en/api/plugin-api/compilation-hooks.mdx @@ -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; @@ -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']; @@ -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'; diff --git a/website/docs/zh/api/plugin-api/compilation-hooks.mdx b/website/docs/zh/api/plugin-api/compilation-hooks.mdx index 93c3749cdee5..be2ba8738ac5 100644 --- a/website/docs/zh/api/plugin-api/compilation-hooks.mdx +++ b/website/docs/zh/api/plugin-api/compilation-hooks.mdx @@ -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; @@ -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']; @@ -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';