🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

postcss-fontsource-url

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-fontsource-url

PostCSS plugin to rewrite @fontsource CSS URLs

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
7
16.67%
Maintainers
1
Weekly downloads
 
Created
Source

postcss-fontsource-url

NPM version License

PostCSS plugin that transforms @fontsource src CSS properties values to point URLs to your own custom directory.

Installation

npm add --save-dev postcss-fontsource-url

Usage

Move the @fontsource fonts to your public directory:

📁 dist
└── 📁 assets
    └── 📁 fonts
        ├── roboto-mono-latin-400-normal.woff
        └── roboto-mono-latin-400-normal.woff2
/* stylesheet.css */
@import '@fontsource/roboto-mono/400.css';
// postcss.config.mjs
import postcssFontsourceUrl from 'postcss-fontsource-url';

export default {
  plugins: {
    postcssFontsourceUrl({directory: '/assets/fonts'}),
  },
};

Alternative

If you want a more complex solution for the problem, you can use postcss-url:

// postcss.config.mjs
import postcssUrl from 'postcss-url';

export default {
  plugins: {
    postcssUrl({
      url(asset) {
        // Rewrite @fontsource fonts URLs to use the `/assets/fonts` folder
        // instead of the default `./files/` path.
        if (asset.url.startsWith('./files/')) {
          return `/assets/fonts/${asset.url.slice('./files/'.length)}`;
        }

        return asset.url;
      },
    }),
  },
};

Keywords

postcss

FAQs

Package last updated on 24 Apr 2025

Did you know?

Socket

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.

Install

Related posts