Configuration
While Pollen provides a default bundle of robust, useful low-level variables to build your project with (under pollen-css/pollen.css). It also comes with a build tool to generate your own custom CSS bundle instead.
Start by creating a pollen.config.js file in the root of your project that exports either a function or an object. See the full list of configuration options below.
pollen.config.js
1
module.exports = {
2
// Config options
3
}
Copied!
Once you have a configuration file, run the included pollen CLI tool. Either install pollen-css globally, or run the tool in an NPM script or with npx.
Global install
Local install
1
$ npm i -g pollen-css
2
$ pollen
Copied!
1
npm i pollen-css
2
npx pollen
Copied!
Then import/link to the output stylesheet in your project instead of the default Pollen export
1
import './pollen.css';
Copied!

Managing Pollen builds in production

Since the output CSS is a generated file, we recommend excluding this output from version control like git and running the pollen build tool along with the rest of your build pipeline, in a CI step or similar. You can do this with a prebuild script in package.json
package.json
1
{
2
"scripts": {
3
"prebuild": "pollen"
4
}
5
}
Copied!

Config options

Option
Default
Description
output
./pollen.css
File path of the generated Pollen stylesheet to use in your project
modules
Pollen default values
Pollen module configuration, see Configuring Modules
1
module.exports = {
2
output: './styles/pollen.css',
3
modules: {
4
// Module config
5
}
6
}
Copied!

CLI options

Option
Default
Description
-c, --config
./pollen.config.js
Path to your Pollen config file
-o, --output
Value of output in config file
File path to generated Pollen stylesheet
1
pollen -c ./pollen-dev.config.js -o ./styles/pollen-dev.css
Copied!

Typescript support

Pollen exports its config as a Config type, which you can use to annotate your config file with JSDoc typings
1
/** @type {import('pollen-css').Config} */
2
module.exports = {}
Copied!
Alternatively use the included defineConfig() helper to get typescript support without JSDoc annotation
1
const { defineConfig } = require('pollen-css/utils');
2
3
module.exports = defineConfig({ ... });
Copied!
Last modified 1mo ago
Copy link
Edit on GitHub