npm i gulp-fa-minify
A utility Gulp plugin to remove unused Icons from FontAwesome 5/6 when using SVG with JavaScript.
The JavaScript files included in FontAwesome 5/6 can lead to a bundle size increase of ~900kb (or even >2.5MB if you have Access to the Pro Version). Only including the needed Icons can lead to a massive size reduction and performance increase.
Use it as a normal gulp plugin in your workflow:
const usedIcons = {
fal: [],
far: ['copy'],
fas: ['copy', 'gears', 'address-book'],
fab: []
};
return gulp.src('./path/to/font-awesome/all.js')
.pipe(faMinify(usedIcons))
.pipe(gulp.dest('./'));
(Full Example: gulpfile.js )
Attention: Only works with the non minified JavaScript files because this plugin uses regular expressions to find the defined icons. But adding the gulp-uglify for example is a simple one-liner.