(Huge thanks to https://github.com/koluch/esbuild-plugin-sass which this is based off)
Plugin for esbuild to support PostCSS
npm i esbuild @deanc/esbuild-plugin-postcssor yarn
yarn add esbuild @deanc/esbuild-plugin-postcssCreate file src/test.css:
input[type="text"] {
border-radius: 1px;
}Create file src/index.js:
import "./test.css";Create file build.js:
const esbuild = require("esbuild");
const autoprefixer = require("autoprefixer");
const postCssPlugin = require("@deanc/esbuild-plugin-postcss");
esbuild
.build({
entryPoints: ["src/index.js"],
bundle: true,
outfile: "bundle.js",
plugins: [
postCssPlugin({
plugins: [autoprefixer],
}),
],
})
.catch((e) => console.error(e.message));Run:
node build.jsFile named bundle.css with appropriate postcss plugins applied.