Registry / http-networking / esbuild-style-plugin

esbuild-style-plugin

JSON →
library1.6.3jsnpmunverified

An esbuild plugin for processing CSS, SASS, LESS, and STYLUS files. Version 1.6.3. It handles CSS modules via PostCSS, supports reading postcss.config.js, and extracts CSS by default. Preprocessors are not bundled; you install only what you need (sass, less, stylus). It ships TypeScript definitions and supports both ESM and CJS builds. Key differentiators: SSR-friendly (extract: false keeps CSS modules mapping), dynamic preprocessor imports, and built-in PostCSS integration without requiring additional configuration plugins.

npm install esbuild-style-plugin
INSTALL
IMPORT
SIG · ESBUILD-STYLE-PLUG
E
esbuild-style-plugin
http-networkingjavascriptv1.6.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

stylePlugin
✓ import stylePlugin from 'esbuild-style-plugin'
✗ const stylePlugin = require('esbuild-style-plugin')
Default export is ESM-friendly; require() works but preferred import for consistency.
stylePlugin
✓ import stylePlugin from 'esbuild-style-plugin'
✗ import { stylePlugin } from 'esbuild-style-plugin'
The package exports a default function, not a named export. Named import will give undefined.
StylePluginOptions
✓ import type { StylePluginOptions } from 'esbuild-style-plugin'
TypeScript types are available for the options object, exported as a named type.

Basic esbuild build using esbuild-style-plugin with all options explicitly set, showing ESM import and TypeScript usage.

import esbuild from 'esbuild'; import stylePlugin from 'esbuild-style-plugin'; await esbuild.build({ entryPoints: ['./src/index.js'], bundle: true, outdir: './dist', plugins: [ stylePlugin({ extract: true, cssModulesMatch: '\.module\.css$', renderOptions: { sassOptions: {}, lessOptions: {}, stylusOptions: {} }, postcss: { plugins: [] }, postcssConfigFile: false }) ] });
Debug
Known issues
gotchaPreprocessors are not bundled; must install sass, less, or stylus separately or get runtime error.
fix
Run npm i -D sass (or less/stylus) for the preprocessor you need.
affects: >=1.0
gotchaCSSNano should not be used as a PostCSS plugin; it will cause issues and duplicates esbuild minification.
fix
Remove cssnano from postcss.plugins; let esbuild handle minification.
affects: >=1.0
deprecatedpostcssConfigFile: true uses root folder — may be ambiguous in monorepos.
fix
Use an absolute path string instead of boolean true for clarity.
affects: >=1.0
gotchaWhen extract: false, CSS is not emitted; only CSS modules class mappings are available for SSR.
fix
Set extract: true to output CSS files, or keep false for SSR and handle CSS injection server-side.
affects: >=1.0
Errors
Common errors & fixes
Cannot find module 'sass'
Missing preprocessor installation.
fix
Install the preprocessor: npm i -D sass (or less, stylus)
stylePlugin is not a function
Using named import instead of default import.
fix
Use 'import stylePlugin from 'esbuild-style-plugin'' instead of 'import { stylePlugin }'
TypeError: Cannot read properties of undefined (reading 'module')
postcss not installed when using CSS modules or PostCSS options.
fix
Install postcss: npm i -D postcss
Upgrade
Version history
1.6.3latest on npm
Audit
Dependencies
postcssoptionalUsed internally to handle CSS modules and PostCSS plugins; must be installed explicitly if you use PostCSS features.
sassoptionalPreprocessor for SASS/SCSS files; not bundled by default — install only if needed.
lessoptionalPreprocessor for LESS files; not bundled by default — install only if needed.
stylusoptionalPreprocessor for STYLUS files; not bundled by default — install only if needed.
Agent activity
8 hits · last 30 days
node
6
Bingbot
1
OpenAI (training)
1
Resources
esbuild-style-plugin — npm install esbuild-style-plugin · libregistry