apps/public-docsite-v9/src/Icons/IconsUsage.mdx
import { Meta } from '@storybook/addon-docs/blocks';
<Meta title="Icons/Advanced Usage" /> <h1 className="sbdocs-title">Advanced Usage</h1>Fluent icons can also be consumed as a font. The API is the same as the React element icons, and there are tools to allow you to more seamlessly integrate the font icons
into your application. You will also be able to only bundle the font icons you need in your application using the @fluentui/react-icons-font-subsetting-webpack-plugin package.
If optimization.usedExports is enabled (as it is by default), this plugin will subset the font files to only include the glyphs actually used by your build.
Here is how you set up your webpack configuration to use font files in your application:
// webpack.config.js
const {
default: FluentUIReactIconsFontSubsettingPlugin,
} = require('@fluentui/react-icons-font-subsetting-webpack-plugin');
module.exports = {
module: {
rules: [
// Treat the font files as webpack assets
{
test: /\.(ttf|woff2?)$/,
type: 'asset',
},
],
},
resolve: {
// Include 'fluentIconFont' to use the font implementation of the Fluent icons
conditionNames: ['fluentIconFont', 'import'],
},
plugins: [
// Include this plugin
new FluentUIReactIconsFontSubsettingPlugin(),
],
};
Pros:
Cons: