A Webpack Plugin that minifies your included FontAwesome 5 CSS and fonts by only bundling the icons you are actually using.
Notice: If you are using FontAwesome 4.x, you should be using version 0.1 of this plugin!
npm install --save-dev font-awesome-minify-plugin
# or
yarn add --dev font-awesome-minify-plugin
const FontAwesomeMinifyPlugin = require("font-awesome-minify-plugin");
module.exports = {
// ...
plugins: [
// ...
new FontAwesomeMinifyPlugin({
srcDir: helpers.root("app/")
})
]
}
TypeScript example:
import "@fortawesome/fontawesome-free-webfonts/css/fontawesome.css";
import "@fortawesome/fontawesome-free-webfonts/css/fa-regular.css";
import "@fortawesome/fontawesome-free-webfonts/css/fa-solid.css";
import "@fortawesome/fontawesome-free-webfonts/css/fa-brands.css";
new FontAwesomeMinifyPlugin(options: object)
Name | Type | Default | Description |
---|---|---|---|
additionalClasses | {Array<String>} | [] | Additional FontAwesome CSS classes that should be included regardless of whether they occur or not |
blacklist | {Array<String>} | All non-icon classes | CSS Classes that are prohibited from being included |
prefix | {String} | fa | The icon prefix |
srcDir | {String} | ./ | Determines the folder in which to look for the usage of FontAwesome classes, see globPattern as well |
globPattern | {String} | **/* | Determines the glob pattern that determines which files are analyzed |
debug | {Boolean} | false | Print additional debug information |
The plugin hooks into the process of Webpack's module resolution and when a file matching any of FontAwesome's CSS filenames is found it does the following:
prefix
, globPattern
and srcDir
options)I would like to express my gratitude towards these projects:
Without them, this plugin wouldn't be possible.
Thanks to the people behind the awesome FontAwesome library as well!
Version | Tag | Published |
---|---|---|
1.1.0 | latest | 3yrs ago |