Shilp Config File
shilp.config.js controls how Shilp CSS behaves. It shapes the system before
CSS is generated.
In other words, it is the brain of Shilp CSS. It works kind of similar to Tailwind CSS v3.
If you understand this file, you understand how Shilp CSS works.
The Structure
Below is the full shape of the config file. Almost everything is just nested objects.
shilp.config.jsconst shilpConfig = { // scss config: dev environment + build time scss: { imports: "", options: (options) => { ... } }, // Build & Output source: "" or [], purge: (options) => { ... }, colorFormat: "oklch" or "rgb", transpile: (options) => { ... }, // override default config: replaces objects completely values: { ... }, valueResolvers: { ... }, theme: (values) => { ... } or { ... }, inlineTheme: { ... }, properties: { ... }, intents: { ... }, components: { ... }, mixins: { ... }, // extend default config: adds / modifies root-level config (deep merge) extend: { values: { ... }, valueResolvers: { ... }, theme: (values, inBuiltTheme) => { ... } or { ... }, inlineTheme: { ... }, properties: { ... }, intents: { ... }, components: { ... }, mixins: { ... } } } export default shilpConfig;
How Config File is Processed
The process is simple:
- Load internal default config to root-level
- Override internal default config with your root-level config if provided
- Deep merge from
shilpConfig.extendto root-level config - Freeze the final configuration
- Start generating CSS
Root level keys replace defaults. extend keys merge into defaults.
Root Level
Extend
Inside extend, everything is deep merged with the root-level config or in
other words adds / modifies part of the root-level config.
Extend theme configconst shilpConfig = { source: "react", // other config extend: { theme: { ... } } } export default shilpConfig;
In most cases, extend is safer. Use root-level replacement only when you want full control.
Core System Config
These define how Shilp CSS used to generates plain css.
At a high level:
SCSS Config
Controls how SCSS is processed during development and build time.
| Option | Type | Description |
|---|---|---|
scss.imports | string | SCSS modules to preload before processing |
scss.options | function | Returns SCSS compilation options passed to the SCSS JS API |
imports
A string of SCSS imports that are automatically included before processing.
Useful when your styles depend on shared SCSS.
For example: Mixins uses list module from SCSS so it is
added (@use "sass:list";) to the imports internally by default.
options
A function that receives the SCSS compilation options.
| Option | Type | Description |
|---|---|---|
options.defaultOptions | object | Defaults options passed to the Purge CSS |
options.css | string | Raw CSS string with SCSS modules imports (added at top) |
options.filePath | string | Path of the raw CSS string (css files without SCSS modules imports) |
Default options for SCSSconst defaultOptions = { // No Shilp CSS default options, configured as of now };
You can modify or replace the options before they are passed to SCSS.
If you don’t define scss.options config, defaultOptions are passed to
SCSS.
Build & Output Config
After css is generated, these options optimizes it.
source
It defines which markup files are scanned for removing unused styles (purging).
| Source | Description |
|---|---|
null | It skips purging completely |
"react" | Adds react.js sources ["./dist/**/*.{html,js}"] |
"vue" | Adds vue.js sources ["./dist/**/*.{html,js}"] |
[...] | For Custom globs file pattern |
By default, Shilp CSS recommends scanning build output folders for more accurate and efficient purging.
purge
A function that receives the final purge options for removing unused styles.
| Option | Type | Description |
|---|---|---|
options.defaultOptions | object | Defaults options passed to the Purge CSS |
options.css | string | Raw CSS string |
options.filePath | string | Path of the raw CSS string |
Default options for Purge CSSconst defaultOptions = { content: ["./dist/**/*.{html,js}"], // as source is "react" css: [{ raw: css }], // css is raw styles string safelist: [], // keep below options false for now, more will be explained in `/docs/life-cycle/purging` variables: false, keyframes: false, fontFace: false, };
You can modify or replace the options before they are passed to Purge CSS.
If you don’t define purge config, defaultOptions are passed to Purge
CSS.
See: Purge CSS Options
colorFormat
Default value is "oklch".
All the colors authoring happens in OKLCH format irrespecitve of the value of this option.
| Color Format | Output |
|---|---|
"oklch" | stays as oklch format |
"rgb" | oklch format converted to rgb format |
Important Note For RGB Format
If you set colorFormat: "rgb", It will conflict with @supports rules that
check for oklch support.
If your project relies on @supports (color: oklch(...)) { ... } checks, keep
the default colorFormat: "oklch".
transpile
A function that receives the final Lightning CSS options for styles optimization.
| Option | Type | Description |
|---|---|---|
options.defaultOptions | object | Defaults options passed to the Lightning CSS |
options.DEFAULT_BROWSER_TARGET | string | Shilp CSS baseline. default: "since 2023-01-31" |
options.createCSSTargets | function | Helper function to create baseline browser target |
options.css | string | Raw CSS string |
options.originalCSS | string | Raw CSS string in OKLCH format (always) |
options.filePath | string | Path of the raw CSS string |
Default options for Lightning CSSconst defaultOptions = { // `finalCSS` is after color format conversion with `colorFormat` option code: Buffer.from(finalCSS), minify: true, sourceMap: true, // DEFAULT_BROWSER_TARGET: since 2023-01-31 targets: createCSSTargets(DEFAULT_BROWSER_TARGET), nonStandard: { deepSelectorCombinator: true, // vue, angular }, };
You can modify or replace the options before they are passed to Lightning CSS.
If you don’t define transpile config, defaultOptions are passed to
Lightning CSS.
Development vs Build
While running in development (on your local machine):
- Your
.cssfiles are read and processed - Plain CSS is generated
- The result is served to the browser
This happens inside the development environment. It is simply build-time processing happening live.
During production build:
- Your
.cssfiles are read and processed - Plain CSS is generated
- Unused styles are removed (if enabled)
- Final CSS is optimized
- Static CSS file is emitted
Now, Deploy 🚀 and Rock 🤘🏻🪩.