
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
webfonts-loader
Advanced tools
A WebPack loader to automaticaly generate font files and CSS to make your own icon font
A loader that generates fonts from your SVG icons and allows you to use your icons in your HTML.
webfonts-loader
uses the webfonts-generator
plugin to create fonts in any format. It also generates CSS files so that you can use your icons directly in your HTML, using CSS classes.
npm install webfonts-loader
An example of usage can be found in the test/
directory of this repository.
Add this rule to your Webpack config:
{
test: /\.font\.js/,
loader: ExtractTextPlugin.extract({
use: [
'style-loader',
'css-loader',
'webfonts-loader'
]
})
}
So that each font configuration file will be loaded using this rule.
The config file allows you to specify parameters for the loader to use. Here is an example configuration file:
// myfont.font.js
module.exports = {
'files': [
'./myfont/*.svg'
],
'fontName': 'myfonticons',
'classPrefix': 'myfonticon-',
'baseSelector': '.myfonticon',
'types': ['eot', 'woff', 'woff2', 'ttf', 'svg'],
'fileName': 'app.[fontname].[hash].[ext]'
};
Then you have to require the configuration file:
// entry.js
require('./myfont.font');
The loader will then generate:
And there you are - your webfont is done. Now, here is one thing: You can use JavaScript too. A useful thing is, that there are two additional options that I did not mention:
baseSelector
, String
The base CSS selector, under which each icon class is to be created.
See webfonts-generator#templateoptions
classPrefix
, String
The prefix to be used with each icon class.
See webfonts-generator#templateoptions
cssTemplate
, String
See webfonts-generator#csstemplate
embed
, Boolean
If true the font is encoded in base64 and embedded inside the @font-face
declaration, otherwise font files are written to disk.
Default: false
hashLength
, Number
Optional. The length of hash in fileName
.
Min: 8
Max: 32
Default: 20
fileName
, String
The generated font file names. These elements can be used:
[fontname]
: the value of the fontName
parameter[ext]
: the extension of the font file being generated (eot
, ...)[hash]
: the hash of the current compilation[chunkhash]
: the hash of the SVG filesfiles
, Array
See webfonts-generator#files
fontName
, String
See webfonts-generator#fontname
formatOptions
, Object
See webfonts-generator#formatoptions
rename
, Function
See webfonts-generator#rename
types
, Array
See webfonts-generator#types
FAQs
A WebPack loader to automatically generate font files and CSS to make your own icon font
We found that webfonts-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.