Rspack

Add @postcss-go/rspack-loader to your CSS rule. It calls the Go engine directly and does not depend on postcss or the official postcss-loader. By default it discovers postcss.config.js from the input file, same as the CLI. You can keepcss-loader or Rspack's builtin:css-loader after this loader.

Open live playground →

terminal
pnpm add -D @postcss-go/core @postcss-go/rspack-loader autoprefixer @rspack/core @rspack/cli css-loader style-loader
postcss.config.js
export default {
  plugins: {
    autoprefixer: {},
  },
};
rspack.config.js
export default {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: ['style-loader', 'css-loader', '@postcss-go/rspack-loader'],
      },
    ],
  },
};

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

rspack.config.js
import autoprefixer from 'autoprefixer';

export default {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [
          'style-loader',
          'css-loader',
          {
            loader: '@postcss-go/rspack-loader',
            options: {
              sourceMap: true,
              postcssOptions: {
                config: false,
                plugins: [autoprefixer()],
              },
            },
          },
        ],
      },
    ],
  },
};
src/styles.css
.button {
  display: flex;
  gap: 0.5rem;
}

You can still run the CLI for a bundler-free CSS pass:

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