A Lektor plugin for building CSS files
Project description
lektor-cssbuild is a plugin for the Lektor static site generator that integrates CSS manipulation tools into the build process. The tools that it uses are:
libsass-python is run before the Lektor build to generate a CSS file.
uncss is run after the Lektor build to remove unused CSS.
rcssmin is run as the last step to minify the CSS.
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 uncss:
npm install --save-dev uncss
Create a configuration file configs/cssbuild.ini and set the tool paths (assuming that your source sass file is style/sass/main.scss):
[sass] source = src:style/sass/ output = src:assets/static/ [uncss] output = dst:static/main.nested.css [cssmin] source = dst:static/main.nested.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 static/main.nested.css file in the build directory.
The generated static/main.nested.css file is minified and the result is written into the main.css file in the same directory.
During uncss, the ignore option can be used to make sure to keep some selectors:
[uncss] output = src:style/css/main.css ignore = "/\.selector1.*/"
0.3.1 (2019-08-10)
Fix npm install bug.
0.3 (2019-08-09)
Replace node-sass with libsass-python.
Replace node-cssmin with python rcssmin.
0.2 (2019-08-06)
Add ignore option to uncss stage.
0.1 (2019-08-06)
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.
Source Distribution
File details
Details for the file lektor-cssbuild-0.3.1.tar.gz
.
File metadata
- Download URL: lektor-cssbuild-0.3.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19407431a501a20dad6a7083d26ba5a1a4e0484487064f0c1a6e9fe9ab0e04ac |
|
MD5 | 97ef7bcfafac440e76f81116625092fe |
|
BLAKE2b-256 | 5cd66ea6d3f3548cbbe2e12c3830d6ff93808d7f44019d6f4a95cb26756de372 |