@metamodern/copy-fontsource

1.0.0 • Public • Published

@metamodern/copy-fontsource

Automagically copy font files from @fontsource/* packages in your dependencies

Install

npm i @metamodern/copy-fontsource

Usage

This package is released as an ES module only. Minimum Node.js version is 14 (latest LTS as of release date). CommonJS require() is not supported.

import { copy } from '@metamodern/copy-fontsource';

const onRender = async () => {
  await copy(process.cwd(), { dist = 'public' });
}; 

API

The module's default export is an async function with the following parameters:

async function(context: string, { dist = 'dist' } = {}): Promise<void>

Required

  • context: path to the project's root directory containing the relevant package.json and node_modules (will be resolved as described here)

Options

  • dist: name of (or path) to the public directory where the files will be copied (will be resolved relative to context)

Notes

The exported function only copies the relevant font files to context/dist. You must also import each typeface's index.css to load the @font-face rules into your bundle.

Readme

Keywords

Package Sidebar

Install

npm i @metamodern/copy-fontsource

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

3.87 kB

Total Files

4

Last publish

Collaborators

  • danielnarey