PostCSS Plugin
Boss CSS ships as a PostCSS plugin that drives parsing and CSS generation.
Stencil note: Stencil projects should skip PostCSS and use npx boss-css watch instead.
If you need to call the PostCSS pipeline programmatically, see Runners.
Usage
// postcss.config.js
module.exports = {
plugins: {
'boss-css/postcss': {},
autoprefixer: {},
},
}
If your project uses "type": "module", use an ESM config instead:
// postcss.config.js
export default {
plugins: {
'boss-css/postcss': {},
autoprefixer: {},
},
}
Options
Use options when you want to override auto defaults:
// postcss.config.js
module.exports = {
plugins: {
'boss-css/postcss': { dirDependencies: false },
autoprefixer: {},
},
}
dirDependencies: emits PostCSSdir-dependencymessages so tooling can watch for new files. Defaults totrueunless a Turbopack env flag is set (TURBOPACKor__NEXT_TURBOPACK), in which case it disables directory dependencies to avoid Turbopack errors. Settrueorfalseto override.
Entry stylesheet
The plugin runs when it processes the configured stylesheet path (default: .bo$$/styles.css) and any *.boss.css boundary files.
/* .bo$$/styles.css */
Make sure this file is included in your build pipeline (or imported by your app). Boundary files should be imported explicitly where you want their scoped styles to load and are overwritten on each build.
What happens on build
- The plugin expands
contentglobs from.bo$$/config.js. - Each file is parsed for className syntax, plus JSX (
$$) when the JSX parser is enabled. - CSS rules are emitted to
.bo$$/styles.cssand any*.boss.cssboundaries. - The generated runtime in
.bo$$/index.jsis updated (unlessclassname-onlyis selected), and PostCSS waits for that write to finish before completing the run. - See CSS Boundaries for how boundary files are discovered and hoisted.
Troubleshooting
- If CSS is not generating, confirm that
.bo$$/styles.cssis part of your build. - Check that
contentglobs include the files you want to parse. - If a file cannot be parsed, Boss emits a PostCSS warning with the file path (for example:
[boss-css] Failed parsing src/app.tsx: ...). Fix the parse error and rerun.