KScript docs
EN

Stylesheets

Building stylesheets

kscript css compiles every stylesheet in the current folder, or the files and folders you name. It skips node_modules, .git and partials whose names start with _:

CommandWhat it does
kscript cssEvery stylesheet in this folder.
kscript css --out public/cssWrite the results to another folder.
kscript css --var dark=trueSet $vars.dark.
kscript make css siteStart a new site stylesheet.

With --out, when two stylesheets would be written to the same file, nothing is built and the command says which.

A script may compile a stylesheet too. @stylesheet() returns the CSS as text, so you can write it wherever you like. Add import KScript.Style first:

<import package="KScript.IO" />
<import package="KScript.Style" />

<do>@write_text(./public/theme.css, @stylesheet('theme.ks.css', { dark: true }))</do>
import KScript.IO
import KScript.Style

@write_text(./public/theme.css, @stylesheet('theme.ks.css', { dark: true }))

Serving stylesheets

kscript serve compiles theme.ks.css on each request for theme.css, unless a real theme.css is there, and never serves the .ks.css source itself. When a stylesheet fails, the error comes back as a CSS comment with status 500. The Team example site defines its styles in Example Sites/team/site.ks.css, and links to /site.css from its layout.

Sass

A .ks.scss or .ks.sass stylesheet compiles to ordinary Sass, which then goes through your own Sass compiler. Run kscript css on the KScript source before the project's Sass compiler runs.