@fluentui/react-icons-font-subsetting-webpack-plugin 2.0.330 → 2.0.332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/lib/index.js +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,20 @@ import { DeleteRegular } from '@fluentui/react-icons/fonts/delete';
|
|
|
25
25
|
|
|
26
26
|
Atomic imports provide better tree-shaking and faster build times for applications using a small number of icons.
|
|
27
27
|
|
|
28
|
+
### 3. Using headless atomic imports from `@fluentui/react-icons/headless/fonts/*`
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
// Headless font atoms — no Griffel runtime.
|
|
32
|
+
// You MUST also import the headless font CSS so the @font-face declarations and
|
|
33
|
+
// font files enter the module graph (the headless atoms don't import them):
|
|
34
|
+
import '@fluentui/react-icons/headless/fonts/styles.css';
|
|
35
|
+
import { AddRegular, AddFilled } from '@fluentui/react-icons/headless/fonts/add';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The plugin subsets the same shared font files used by the standard API, based on the headless icons you actually use. Because the font files arrive via `styles.css`, your config needs a CSS loader (e.g. `css-loader`) so the `url(...)` references resolve into webpack assets.
|
|
39
|
+
|
|
40
|
+
> **Tip 💡:** You don't have to write atomic headless imports by hand. Pair this plugin with [`@fluentui/react-icons-atomic-webpack-loader`](../react-icons-atomic-webpack-loader) using `{ headless: true, iconVariant: 'fonts' }` — it rewrites plain barrel imports (`import { AddFilled } from '@fluentui/react-icons'`) into headless font atoms, which this plugin then subsets. You still import `@fluentui/react-icons/headless/fonts/styles.css` yourself.
|
|
41
|
+
|
|
28
42
|
## Usage
|
|
29
43
|
|
|
30
44
|
### With `fluentIconFont` condition
|
package/lib/index.js
CHANGED
|
@@ -39,11 +39,13 @@ const FONT_FILES_BASE_NAMES = [
|
|
|
39
39
|
];
|
|
40
40
|
const FONT_EXTENSIONS = ['.ttf', '.woff', '.woff2'];
|
|
41
41
|
/**
|
|
42
|
-
* Match both chunk files and atomic font imports
|
|
43
|
-
*
|
|
44
|
-
* - lib/
|
|
42
|
+
* Match both chunk files and atomic font imports, for the standard (Griffel)
|
|
43
|
+
* and headless APIs:
|
|
44
|
+
* - lib/fonts/sizedIcons/chunk-0.js (chunk-based, standard)
|
|
45
|
+
* - lib/atoms/fonts/access-time.js (atomic imports, standard)
|
|
46
|
+
* - lib/atoms/headless-fonts/access-time.js (atomic imports, headless)
|
|
45
47
|
*/
|
|
46
|
-
const REACT_ICONS_FONT_MODULE_IMPORT_PATTERN = /react-icons[\/\\]lib(-cjs)?[\/\\](fonts[\/\\](sizedIcons|icons)[\/\\]chunk-\d+|atoms[\/\\]fonts[\/\\][\w-]+)\.js$/;
|
|
48
|
+
const REACT_ICONS_FONT_MODULE_IMPORT_PATTERN = /react-icons[\/\\]lib(-cjs)?[\/\\](fonts[\/\\](sizedIcons|icons)[\/\\]chunk-\d+|atoms[\/\\](headless-)?fonts[\/\\][\w-]+)\.js$/;
|
|
47
49
|
class FluentUIReactIconsFontSubsettingPlugin {
|
|
48
50
|
/**
|
|
49
51
|
* Entry point for the Webpack plugin that registers hooks to perform font subsetting for `@fluentui/react-icons`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-icons-font-subsetting-webpack-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.332",
|
|
4
4
|
"description": "Webpack plugin to subset the icon fonts used by @fluentui/react-icons based on which icons are used.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|