1.2.0 • Published 12 months ago

font-slice-plugin v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

Font Slice Webpack Plugin

This plugin is used to split font files into single font files, so that font files can be loaded on demand in different pages.

It's my first time to write a webpack plugin. I hope it can help you.

usage:

{
  webpack: (
    config,
    { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }
  ) => {
    config.plugins.push(
      new FontSlicePlugin({
        fontDirectory: "public/web_fonts", // font directory
        assetsDirectory: ".next/static", // assets directory
        tempDirectory: ".temp", // temp directory, please make sure it's in .gitignore
      })
    );
    return config;
  };
}

Use Script Instead of Plugin?

You can use font-slice-plugin in your npm script now!

package.json

{
  "scripts": {
    "build:fonts": "node scripts/build-fonts.js"
  }
}

scripts/build-fonts.js

const { fontSliceWorker } = require("font-slice-plugin");

fontSliceWorker({
  fontDirectory: "public/web_fonts", // font directory
  assetsDirectory: "public/static", // assets directory
  tempDirectory: ".temp", // temp directory, please make sure it's in .gitignore
});

(in your terminal)

npm run build:fonts
1.2.0

12 months ago

1.1.0

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago