Vite

Add @postcss-go/vite-loader to your Vite plugins. It runs before Vite's built-in CSS pipeline, calls the Go engine directly, and does not depend on postcss. By default it discovers postcss.config.js from each input file, same as the CLI.

Open live playground →

terminal
pnpm add -D @postcss-go/core @postcss-go/vite-loader autoprefixer vite
postcss.config.js
export default {
  plugins: {
    autoprefixer: {},
  },
};
vite.config.js
import postcssGo from '@postcss-go/vite-loader';

export default {
  plugins: [postcssGo()],
};

Pass postcssOptions inline when you want to disable config lookup or set plugins in the Vite config. postcssOptions can also be a function that receives mode,env, file, and the Vite config.

vite.config.js
import postcssGo from '@postcss-go/vite-loader';
import autoprefixer from 'autoprefixer';

export default {
  plugins: [
    postcssGo({
      postcssOptions: {
        config: false,
        plugins: [autoprefixer()],
      },
    }),
  ],
};
src/styles.css
.button {
  display: flex;
  gap: 0.5rem;
}

Unless css.postcss is already set, the plugin clears Vite's PostCSS plugin list so the same postcss.config.* is not run twice. You can still run the CLI for a bundler-free CSS pass:

package.json
{
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "build:css": "postcss-go src/**/*.css --base src --dir dist/css --no-map"
  }
}