Registry / web-framework / esbuild-plugin-postcss2-esbuild1101

esbuild-plugin-postcss2-esbuild1101

JSON →
library0.0.9jsnpmunverified

An optimized, type-friendly PostCSS plugin for esbuild (v0.0.9). Supports CSS preprocessors (Sass, Less, Stylus) and CSS modules out of the box. Based on esbuild-plugin-postcss but with improved TypeScript definitions and performance. Works with esbuild 0.11+. Requires peer dependencies: postcss@8.x and optionally sass, less, or stylus. Minimal configuration needed; automatically resolves postcss.config.js.

npm install esbuild-plugin-postcss2-esbuild1101
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-POS
E
esbuild-plugin-postcss2-esbuild1101
web-frameworkjavascriptv0.0.9
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.

default
✓ import postCssPlugin from 'esbuild-plugin-postcss2'
✗ const postCssPlugin = require('esbuild-plugin-postcss2')
Package supports both ESM and CJS; default export is the plugin function.
Options
✓ import type { Options } from 'esbuild-plugin-postcss2'
✗ import { Options } from 'esbuild-plugin-postcss2'
Options is a type export, not a value. Use `import type` in TypeScript.
PostCSSPlugin
✓ import postCssPlugin from 'esbuild-plugin-postcss2'
There is no named export; only default export.

Bundles a CSS file with esbuild, applies Autoprefixer via PostCSS, and outputs to dist/bundle.css.

import esbuild from 'esbuild'; import postCssPlugin from 'esbuild-plugin-postcss2'; import autoprefixer from 'autoprefixer'; await esbuild.build({ entryPoints: ['src/index.css'], outfile: 'dist/bundle.css', bundle: true, plugins: [ postCssPlugin({ plugins: [autoprefixer], }), ], }); console.log('Build complete.');
Debug
Known issues
gotchaCSS modules are enabled by default. If you don't want CSS modules, you must explicitly set modules: false.
fix
Set modules: false in options if you don't need CSS modules.
affects: >=0.0.1
gotchaPreprocessors (Sass, Less, Stylus) are not automatically installed. You must add them as devDependencies yourself.
fix
Install the required preprocessor: npm install -D sass (or less, stylus).
affects: >=0.0.1
deprecatedThe export from 'esbuild-plugin-postcss2' changed from a named export to a default export in v0.0.4.
fix
Use default import: import postCssPlugin from 'esbuild-plugin-postcss2' instead of import { postCssPlugin } from 'esbuild-plugin-postcss2'.
affects: >=0.0.1 <0.0.4
breakingPeer dependency postcss changed from ^7.x to 8.x in v0.0.6.
fix
Ensure postcss@8.x is installed.
affects: >=0.0.6
gotchaThe plugin does not automatically resolve postcss.config.js. You must pass PostCSS plugins manually or configure via options.
fix
Pass plugins array to postCssPlugin().
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'sass'
Sass is not installed even though it's a peer dependency.
fix
Install sass: npm install -D sass
TypeError: postCssPlugin is not a function
Using named import instead of default import in older versions.
fix
Use default import: import postCssPlugin from 'esbuild-plugin-postcss2'
Error: PostCSS plugin requires PostCSS 8.x
peer dependency version mismatch (postcss 7.x installed).
fix
Update postcss to 8.x: npm install postcss@8
Error: Cannot use import statement outside a module
Using ESM syntax in a CommonJS project without type:module.
fix
Use require() instead: const postCssPlugin = require('esbuild-plugin-postcss2')
Error: [postcss-modules] No such file or directory
CSS modules output path is incorrect or not writable.
fix
Check the modules.getJSON path or set modules to false to disable.
Upgrade
Version history
0.0.9latest on npm
Audit
Dependencies
postcssrequiredCore peer dependency for PostCSS processing
sassoptionalRequired for Sass/SCSS preprocessing
lessoptionalRequired for Less preprocessing
stylusoptionalRequired for Stylus preprocessing
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-plugin-postcss2-esbuild1101 — npm install esbuild-plugin-postcss2-esbuild1101 · libregistry