Skip to main content

A Lektor plugin for building CSS files

Project description

PyPI version.

lektor-cssbuild is a plugin for the Lektor static site generator that integrates CSS management tools into the build process. These are the tools that it uses:

  • node-sass is run before the Lektor build to generate a CSS file.
  • uncss is run after the Lektor build to remove unused CSS.
  • node-cssmin is run as the last step to minify the CSS.

This plugin does not use a JavaScript task runner. It runs the command-line executables of these tools.

To use the plugin, add it to your project:

lektor plugin add lektor-cssbuild

Create a package.json file (the name and version aren’t significant for the plugin):

  "name": "my-project-cssbuild",
  "version": "1.0.0",
  "private": true

Install the tools:

npm install --save-dev node-sass uncss cssmin

Create a configuration file configs/cssbuild.ini and set the tool paths:

source = src:style/sass/main.scss
output = src:assets/static/

output = src:style/css/main.css

source = src:style/css/main.css
output = dst:static/main.css

When writing a path, the src prefix refers to a path in the source folders and the dst prefix refers to the build folders.

If any tool section is missing, that tool will be skipped.

To enable the plugin during Lektor build, the cssbuild flag has to be included (same for the server command):

lektor build -f cssbuild

Using the above configuration, the build process will run as follows:

  • The style/sass/main.scss file is read and the file assets/static/main.css is generated.
  • Lektor generates the site artifacts.
  • Based on the generated HTML pages, the unused CSS rules are removed and the result is written into the style/css/main.css file.
  • The style/css/main.css file are minified and the result is written into the static/main.css file in the build directory.

0.1 (unreleased)

  • Initial release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lektor-cssbuild, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size lektor-cssbuild-0.1.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page