npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

esbuild-css-externals-plugin

v0.0.1

Published

esbuild plugin which helps to mark some files references from stylesheet (e.g. images or fonts) as external resources

Readme

esbuild-css-externals-plugin

esbuild plugin which helps to mark some files references from stylesheet (e.g. images or fonts) as external resources

Use case

The plugin is useful when images or/and fonts which defined in css file are already located in a public storage for static files. For example, the source code of stylesheet style.css references to image:

.logo {
    background-image: url(/assets/images/logo.svg)
    /* ... omit other styles ... */
}

By default, esbuild does not resolves this path. We need to setup one of available loader. If we use loader file or copy the image file will copied into output directory.

For example if images directory is public/assets/images/ and output directory is public/dist/ we get a copy of file public/assets/images/logo.svg in public/dist/logo.svg. But what if we won't to do this?

This plugin solves this problem. It can marks this image as external and esbuild does not copy this file from source location into output directory.

Install

npm install --save-dev esbuild-css-externals-plugin

Usage

Add a plugin to your esbuild.mjs:

import * as esbuild from 'esbuild'
import cssExternalsPlugin from 'esbuild-css-externals-plugin'

await esbuild.build({
    // ...
    plugins: [
        // ...
        cssExternalsPlugin({
            // options...
        }),
        // ...
    ],
    // ...
})

Using with sass/scss:

import * as esbuild from 'esbuild'
import cssExternalsPlugin from 'esbuild-css-externals-plugin'
import { postcssModules, sassPlugin } from 'esbuild-sass-plugin'

await esbuild.build({
    // ...
    plugins: [
        // ...
        cssExternalsPlugin({
            // options...
        }),
        sassPlugin({
            filter: /\.module\.(s[ac]ss|css)$/,
            type: 'css',
            transform: postcssModules({
                generateScopedName: '[name]__[local]__[hash:base64safe:5]'
            })
        }),
        sassPlugin({
            filter: /global\.(s[ac]ss|css)$/,
            type: 'css'
        })
        // ...
    ],
    // ...
})

Options

filter

This is a regular expression (keep in mind that this is in Go syntax) to filter resources referenced by path.

Default value is /\.(svg|gif|png|jpe?g|webp|ttf|woff2?|otf|eot)$/.

importer

This is a regular expression to filter importer which reference to resource.

Default value is /\.(s[ac]ss|css)$/.

kind

This is a regular expression to filter a kind which says how the path to be resolved is being imported.

Default value is /^url\-token$/.

License

MIT