Registry / devops / esbuild-plugin-postcss

esbuild-plugin-postcss

JSON →
library0.3.0jsnpmunverified

An esbuild plugin for importing CSS/less/scss modules with TypeScript support. Version 0.3.0 is the latest stable release; the package has had infrequent updates. It enables CSS module extraction and automatic .d.ts declaration generation for less files. Differentiators include minimal configuration, built-in declaration file generation, and esbuild-native integration. Compared to alternatives like esbuild-sass-plugin, this plugin focuses on PostCSS ecosystem compatibility and TypeScript module resolution.

devopshttp-networking
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.

Package is ESM-only; CommonJS require will fail in Node ESM context. Use dynamic import or set type:module.

import PluginPostCSS from 'esbuild-plugin-postcss'

Only default export exists; false named import causes undefined.

import PluginPostCSS from 'esbuild-plugin-postcss'

TypeScript type import only available since v0.2.0.

import type { PostCSSPluginOptions } from 'esbuild-plugin-postcss'

Shows esbuild build with PluginPostCSS, including autoprefixer and nested postcss plugins, and declaration generation.

import esbuild from 'esbuild'; import PluginPostCSS from 'esbuild-plugin-postcss'; await esbuild.build({ entryPoints: ['src/index.ts'], bundle: true, outdir: 'dist', plugins: [ PluginPostCSS({ declaration: true, // generate .d.ts for CSS modules plugins: [ require('autoprefixer'), require('postcss-nested'), ], }), ], loader: { '.tsx': 'tsx', '.ts': 'ts', }, });
Debug
Known footguns
breakingv0.2.0 changed export from named 'PluginPostCSS' to default export only.
deprecatedThe 'declaration' option for .d.ts generation works only with Less files; other preprocessors not supported and may be deprecated in future.
gotchaESM-only package; require() in CommonJS module will throw ERR_REQUIRE_ESM.
gotchaWhen using TypeScript, you must add a global module declaration for CSS/less files (e.g., '*.less' => Record<string, string>) to avoid type errors.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
ahrefsbot
3
claudebot
3
Resources