🍕 A Rollup plugin to subset Material Design Icons (MDI) font files.
This plugin requires Node.js v14.16.1+ (LTS recommended).
npm install rollup-plugin-mdi-fontmin @mdi/font fontmin --save-devIf you want to use fontmin 1.x.x version
npm install rollup-plugin-mdi-fontmin @mdi/font fontmin@1 --save-devCreate a rollup.config.js configuration file and import the plugin:
import mdiFontmin from 'rollup-plugin-mdi-fontmin';
export default {
// ...
plugins: [
// ...
mdiFontmin({
names: ['home', 'account', 'settings'], // List of icons to include (required)
}),
],
};Full configuration example:
import mdiFontmin from 'rollup-plugin-mdi-fontmin';
export default {
// ...
plugins: [
// ...
mdiFontmin({
names: ['home', 'account', 'settings'], // List of icons to include (required)
output: 'public/fonts/mdi', // Output directory
silent: false, // Whether to suppress console output
logPrefix: '[mdi]', // Custom log prefix
}),
],
};Then call rollup either via the CLI or
the API.
Type: Array<string>
Required: Yes
A list of Material Design Icons (MDI) names to include in the subset.
These correspond to css class names without the mdi- prefix.
Type: string
Default: 'public/fonts/mdi'
The output directory for the subsetted font files.
Type: boolean
Default: false
Whether to suppress console output.
Type: string
Default: '[mdi-fontmin]'
Prefix for console output.
The plugin will check if the font files already exist in the output directory. If they do, it will skip the generation step. Otherwise, it will:
- Read the Material Design Icons CSS file.
- Parse and extract the glyphs corresponding to the specified icon names.
- Generate the subsetted font files (
.ttf,.eot,.woff,.woff2). - Modify the CSS file to only include the necessary icons and save it to the output directory.