font-config-webpack-plugin
v2.0.3
Published
Preset for font webpack configuration
Downloads
1,247
Readme
font-config-webpack-plugin
Creating a webpack loader configurations can be quite time consuming.
The font-config-webpack-plugin
is part of the common-config-webpack-plugin
suite which tries to provide best practices for the most common loader requirements.
If no mode is explicitly set for the plugin the configuration will adjust depending on your webpack mode setting.
⚙️development mode webpack.config.js
⚙️production mode webpack.config.js
Installation
npm i --save-dev font-config-webpack-plugin
Webpack Config
In most projects you will need to set up project specific options but you can still use all or some common-config-webpack-plugin parts.
const FontConfigWebpackPlugin = require('font-config-webpack-plugin');
module.exports = {
plugins: [new FontConfigWebpackPlugin()],
};
Changing the fonts file name
By default the font-config-webpack-plugin
adds a md5 hash of the font files content to the file name
to allow long-term-caching.
For example: static/media/OpenSans-Regular-webfont.c8ffdeb3.woff
To change the file name path an option called name
can be passed to the font-config-webpack-plugin
.
The name
option supports different placeholders.
const FontConfigWebpackPlugin = require('font-config-webpack-plugin');
module.exports = {
plugins: [
new FontConfigWebpackPlugin({
name: 'fonts/[name].[ext]',
}),
],
};