Registry / web-framework / esbuild-style-plugin-v2

esbuild-style-plugin-v2

JSON →
library1.6.5jsnpmunverified

An esbuild plugin for processing CSS, SASS, LESS, and STYLUS files. Current version 1.6.5. Supports CSS Modules via PostCSS, dynamic preprocessor imports (no bundled dependencies), and SSR-friendly extraction. Can read postcss.config.js for configuration. Written in TypeScript with dual CJS/ESM builds. Fork of esbuild-style-plugin with active maintenance.

npm install esbuild-style-plugin-v2
INSTALL
IMPORT
SIG · ESBUILD-STYLE-PLUG
E
esbuild-style-plugin-v2
web-frameworkjavascriptv1.6.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

stylePlugin
✓ import stylePlugin from 'esbuild-style-plugin-v2'
✗ const stylePlugin = require('esbuild-style-plugin-v2')
Package supports both ESM default import and CJS require. Default export is the plugin function.
PluginOptions
✓ import type { PluginOptions } from 'esbuild-style-plugin-v2'
TypeScript type for plugin options. Only available as type import.
default export
✓ import stylePlugin from 'esbuild-style-plugin-v2'
✗ import { stylePlugin } from 'esbuild-style-plugin-v2'
The plugin function is the default export, not a named export.

Basic esbuild build configuration with SASS support and CSS Modules enabled.

import esbuild from 'esbuild'; import stylePlugin from 'esbuild-style-plugin-v2'; await esbuild.build({ entryPoints: ['src/index.ts'], outfile: 'dist/bundle.js', bundle: true, plugins: [ stylePlugin({ cssModulesMatch: /\.module\.(css|sass|scss|less|styl)$/, renderOptions: { sassOptions: { sourceMap: true } }, postcss: { plugins: [] } }) ] });
Debug
Known issues
gotchaPostCSS plugins like cssnano are not supported; use esbuild's minification instead.
fix
Do not include cssnano in the postcss plugins array. Use esbuild's built-in minify option.
affects: >=0.0.0
deprecatedThe plugin is a fork of esbuild-style-plugin which is no longer maintained.
fix
Use esbuild-style-plugin-v2 instead of esbuild-style-plugin.
affects: >=0.0.0
gotchaPreprocessors (sass, less, stylus) are not installed by default; user must install them separately.
fix
Install the required preprocessor: npm i -D sass (or less, stylus)
affects: >=0.0.0
gotchaWhen using TypeScript, importing .module.scss files requires a type declaration.
fix
Add 'esbuild-style-plugin-v2' to the 'types' array in tsconfig.json or add a custom .d.ts declaration.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'sass'
SASS preprocessor not installed; it's not bundled with the plugin.
fix
Install sass: npm i -D sass
Error: [esbuild-style-plugin-v2] You can't use cssnano, it's not supported
Using cssnano as a PostCSS plugin, which is explicitly disallowed.
fix
Remove cssnano from postcss.plugins and use esbuild's minify option instead.
Upgrade
Version history
1.6.5latest on npm
Audit
Dependencies
postcssoptionalUsed for CSS Modules and PostCSS plugin support
sassoptionalRequired for SASS/SCSS preprocessing
lessoptionalRequired for LESS preprocessing
stylusoptionalRequired for STYLUS preprocessing
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-style-plugin-v2 — npm install esbuild-style-plugin-v2 · libregistry