{"id":21266,"library":"esbuild-plugin-postcss2","title":"esbuild-plugin-postcss2","description":"An optimized, type-friendly PostCSS plugin for esbuild with support for CSS preprocessors (Sass, Less, Stylus) and CSS modules. Version 0.1.2 is the latest stable release in the 0.x series. Compared to esbuild-plugin-postcss, it ships TypeScript types and fixes common issues. Peer dependencies include postcss 8.x and optional preprocessor libraries. The plugin auto-enables CSS modules for .module.css files and allows custom module configuration.","status":"active","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/martonlederer/esbuild-plugin-postcss2","tags":["javascript","typescript"],"install":[{"cmd":"npm install esbuild-plugin-postcss2","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-postcss2","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-postcss2","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: PostCSS is required for plugin functionality","package":"postcss","optional":false},{"reason":"Optional peer dependency for Less preprocessor support","package":"less","optional":true},{"reason":"Optional peer dependency for Sass/SCSS preprocessor support","package":"sass","optional":true},{"reason":"Optional peer dependency for Stylus preprocessor support","package":"stylus","optional":true}],"imports":[{"note":"CommonJS require returns an object with a default property. The default export is a function that creates the plugin.","wrong":"const postCssPlugin = require('esbuild-plugin-postcss2'); postCssPlugin()","symbol":"default","correct":"const postCssPlugin = require('esbuild-plugin-postcss2'); postCssPlugin.default()"},{"note":"ESM default import works directly. The package ships TypeScript types.","wrong":"import { default as postCssPlugin } from 'esbuild-plugin-postcss2';","symbol":"default","correct":"import postCssPlugin from 'esbuild-plugin-postcss2'; postCssPlugin()"},{"note":"TypeScript types are exported for plugin options. Available since first release.","wrong":"","symbol":"Type definitions","correct":"import type { PostCssPluginOptions } from 'esbuild-plugin-postcss2'"}],"quickstart":{"code":"const esbuild = require('esbuild');\nconst postCssPlugin = require('esbuild-plugin-postcss2');\nconst autoprefixer = require('autoprefixer');\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    postCssPlugin.default({\n      plugins: [autoprefixer],\n      modules: {\n        localsConvention: 'camelCase'\n      }\n    })\n  ]\n});","lang":"javascript","description":"Example showing esbuild with postcss-plugin2 using autoprefixer and CSS modules with camelCase class names."},"warnings":[{"fix":"Ensure esbuild version is 0.8.0 or higher.","message":"Plugin requires esbuild >= 0.8.0 (not specified in package.json but used internally)","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Use require('esbuild-plugin-postcss2').default() instead of calling require directly.","message":"Default import via require is an object with .default property","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set modules: false in options to disable CSS modules.","message":"postcss-modules is enabled by default, may cause unexpected behavior if not needed","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Switch to esbuild-plugin-postcss2.","message":"Original esbuild-plugin-postcss package is unmaintained; this fork is the recommended replacement","severity":"deprecated","affected_versions":"0.0.x"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"const postCssPlugin = require('esbuild-plugin-postcss2').default;","cause":"CommonJS require returns an object; you must call .default()","error":"TypeError: postCssPlugin is not a function"},{"fix":"Ensure postcss@8 is installed as a devDependency.","cause":"postcss-modules is incompatible with PostCSS 7","error":"Error: PostCSS plugin postcss-modules requires PostCSS 8"},{"fix":"npm install -D sass","cause":"Sass/SCSS files require sass to be installed","error":"Error: Cannot find module 'sass'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}