Skip to content

Commit 596fbe3

Browse files
committed
docs(magic-comments): document webpackIgnore support in HTML modules
Webpack 5.107 supports the webpackIgnore magic comment inside HTML modules (when experiments.html is enabled). Placing <!-- webpackIgnore: true --> before a tag skips URL resolution for its src/href/srcset attributes, leaving the tag untouched in the emitted HTML. Adds a new HTML Usage section under the existing webpackIgnore docs in api/module-methods. Refs: webpack/webpack#20950
1 parent f992f03 commit 596fbe3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/content/api/module-methods.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,22 @@ We support `webpackIgnore` in the following cases:
183183
184184
T> For other CSS scenarios, [`css-loader` fully supports `webpackIgnore`](/loaders/css-loader/#disable-url-resolving-using-the--webpackignore-true--comment), allowing more flexibility if needed.
185185
186+
**HTML Usage**
187+
188+
<Badge text="5.107.0+" />
189+
190+
When [`experiments.html`](/configuration/experiments/#experimentshtml) is enabled, `webpackIgnore` can be placed as an HTML comment immediately before a tag to skip URL resolution for that tag's `src`, `href`, `srcset`, and similar attributes. The tag is left untouched in the emitted HTML. This mirrors the behavior provided by `html-loader`.
191+
192+
```html
193+
<!-- webpackIgnore: true -->
194+
<img src="https://cdn.example.com/logo.png" />
195+
196+
<!-- webpackIgnore: true -->
197+
<script src="/legacy/external.js"></script>
198+
```
199+
200+
The magic-comment value is parsed with the same context used by the JS and CSS parsers; non-boolean values emit an `UnsupportedFeatureWarning`.
201+
186202
##### webpackChunkName
187203
188204
A name for the new chunk. Since webpack 2.6.0, the placeholders `[index]` and `[request]` are supported within the given string to an incremented number or the actual resolved filename respectively. Adding this comment will cause our separate chunk to be named [my-chunk-name].js instead of [id].js.

0 commit comments

Comments
 (0)