1.0.0 • Published 3 years ago

@metamodern/copy-fontsource v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

@metamodern/copy-fontsource

Automagically copy font files from [@fontsource/](https://github.com/fontsource/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.

1.0.0

3 years ago