Skip to content

Commit e2dfae4

Browse files
mainframevviktorgenaev
andauthored
docs: build-transforms.md to include webpack loader (#1052)
Co-authored-by: viktorgenaev <viktorgenaev@microsoft.com>
1 parent a1d788d commit e2dfae4

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

packages/react-icons/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ Migrating a larger codebase to the new performant atomic imports might be a daun
338338

339339
Use `svg` as the target path. This transformation happens at build time, so your source code remains unchanged while your bundled output gets the full tree-shaking benefits.
340340

341-
👉 **[Build-Time Transform setup (Babel & SWC) →](./docs/build-transforms.md)**
341+
👉 **[Build-Time Transform setup (Babel, SWC & Webpack) →](./docs/build-transforms.md)**
342342

343343
## Atomic API (SVG Sprites) — ⚠️ Alpha
344344

packages/react-icons/docs/build-transforms.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,46 @@ Replace every `svg` segment in the target paths below with your chosen target (`
140140
},
141141
}
142142
```
143+
144+
## Webpack
145+
146+
Install [`@fluentui/react-icons-atomic-webpack-loader`](../../react-icons-atomic-webpack-loader/README.md):
147+
148+
```bash
149+
npm install @fluentui/react-icons-atomic-webpack-loader@alpha --save-dev
150+
```
151+
152+
Add the loader as an `enforce: 'pre'` rule so it runs before other loaders:
153+
154+
```js
155+
// webpack.config.js
156+
module.exports = {
157+
module: {
158+
rules: [
159+
{
160+
test: /\.[mc]?[jt]sx?$/,
161+
enforce: 'pre',
162+
use: ['@fluentui/react-icons-atomic-webpack-loader'],
163+
},
164+
// … your other rules (babel-loader, ts-loader, etc.)
165+
],
166+
},
167+
};
168+
```
169+
170+
> **Note:** Unlike most loaders, do **not** exclude `node_modules` — the loader needs to transform barrel imports inside dependencies too. Files without `@fluentui/react-icons` references are skipped via a fast regex pre-check.
171+
172+
To use font icons instead of SVG, pass the `iconVariant` option:
173+
174+
```js
175+
{
176+
test: /\.[mc]?[jt]sx?$/,
177+
enforce: 'pre',
178+
use: [
179+
{
180+
loader: '@fluentui/react-icons-atomic-webpack-loader',
181+
options: { iconVariant: 'fonts' },
182+
},
183+
],
184+
}
185+
```

0 commit comments

Comments
 (0)