Dart Sass (Embedded) in Python
Project description
Sassquatch
Sassquatch is a Python wrapper for Dart Sass, providing a convenient way to compile Sass/SCSS to CSS in your Python applications.
Installation
Install Sassquatch with your package manager of choice:
uv add sassquatch
# or, good old:
pip install sassquatch
During installation, Sassquatch will automatically download the latest version of Dart Sass for your platform.
Features
- Compile Sass/SCSS from strings, files, or directories
- Full compatibility with Dart Sass's compilation features
- Use as a command-line tool or as a Python library
- Automatic download and management of the Dart Sass binary
Usage
Command Line Interface
Sassquatch follows Dart Sass CLI semantics:
# Compile a file to stdout
sassquatch path/to/input.scss
# Compile a file to a specific output file
sassquatch path/to/input.scss:path/to/output.css
# Compile a directory
sassquatch path/to/input_dir:path/to/output_dir
# Compile from stdin
echo "body { color: red; }" | sassquatch
# Compile with options
sassquatch path/to/input.scss --style=compressed --no-charset
# update embedded sass version:
sassquatch --sass-update
# see all options:
sassquatch --help
Python API
from sassquatch import compile
# Compile a string
css = compile(string='$primary: #333; body { color: $primary; }')
# Compile a file
css = compile(path='styles.scss')
# Compile with options
css = compile(
path='styles.scss',
style='compressed',
no_charset=True,
load_path=['node_modules']
)
Configuration
Sassquatch supports all Dart Sass command-line options:
| Option | Description |
|---|---|
--style |
Output style: expanded or compressed |
--no-charset |
Don't emit a @charset or BOM for CSS with non-ASCII characters |
--error-css |
When compilation fails, emit error messages as CSS |
--load-path |
Path to look for imported files |
--no-source-map |
Disable source map generation |
--source-map-urls |
How to link from source maps to source files: relative or absolute |
--embed-sources |
Embed source file contents in source maps |
--embed-source-map |
Embed source map contents in CSS |
--watch |
Watch for changes and recompile as needed |
--update |
Only compile out-of-date files |
--verbose |
Print more information |
--quiet |
Don't print warnings |
For a full list of options, refer to the Dart Sass documentation.
Implementation Details
Sassquatch is based on Dart Sass (embedded mode) and downloads the latest version of the Dart Sass binary during installation. This ensures you always have access to the most up-to-date Sass features and fixes.
License
This project is licensed under the MIT License.
Acknowledgments
- Dart Sass - The core Sass compiler
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 sassquatch-1.0.1.tar.gz.
File metadata
- Download URL: sassquatch-1.0.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd9dc5612aadf7312710583382d5441ab52731bef4a94a95e550370ba51ff960
|
|
| MD5 |
8e653b173a636811dd2877be6d7b68ad
|
|
| BLAKE2b-256 |
e94bb39adce5a21e054092e60a166a9cc247890627dd19c3ae5effb415d88c34
|