0.1.5 • Published 5 years ago

preload-font-plugin v0.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

preload-font-plugin

A webpack plugin for font preload.

Requirements

Set before html-webpack-plugin.

Installation

$ npm i -D preload-font-plugin

Usage

{
    plugins: [
        new PreloadFontPlugin({
            // relative to process.cwd()
            './src/demo.ttf': {
                rel: 'preload',
                as: 'font',
                type: 'font/ttf',
                crossorigin: 'anonymous',
                preserveQuery: true
            }
        }),
        new HtmlWebpackPlugin({
            chunks: ['app', 'vendors']
        })
}

output

<link rel="preload" type="font/ttf" as="font" href="demo.be372c5a.ttf?ac43b8" crossorigin="anonymous">

Options

A simple object, whose key is the file relative to process.cwd(), preserveQuery query string should be preserved or not, default false. other value as attributes of <link>.