Robust, expressive, and feature-rich CSS superset with dynamic preprocessing capabilities
—
Complete command-line interface for file compilation, watching, CSS conversion, and build integration with options for compression, source maps, debugging, and plugin support.
Core command-line operations for Stylus compilation.
# Compile single file to stdout
stylus input.styl
# Compile file to specific output
stylus input.styl -o output.css
# Compile multiple files
stylus styles/*.styl -o build/
# Compile directory
stylus src/ -o build/Automatic recompilation when files change.
# Watch single file
stylus -w input.styl -o output.css
# Watch directory with compression
stylus -w -c src/ -o build/Convert existing CSS files to Stylus syntax.
# Convert CSS to Stylus (stdout)
stylus --css < input.css
# Convert CSS to Stylus file
stylus --css input.css output.styl
# Convert with custom indentation
stylus --css --indent=" " input.css output.stylControl output format and optimization.
# Compress output CSS
stylus -c input.styl -o output.css
# Include line numbers in output
stylus -l input.styl -o output.css
# Include Firebug debug information
stylus -f input.styl -o output.css
# Generate source maps
stylus -m input.styl -o output.css
# Print compiled CSS to stdout
stylus -p input.styl
# Compare compiled output with existing file
stylus -d input.styl output.cssSpecify directories to search for @import files.
# Single include path
stylus -I ./styles input.styl
# Multiple include paths
stylus -I ./styles -I ./node_modules input.styl
# Include path with compilation
stylus -I ./mixins -c input.styl -o output.cssUse Stylus plugins for extended functionality.
# Use single plugin
stylus -u autoprefixer-stylus input.styl
# Use multiple plugins
stylus -u nib -u autoprefixer-stylus input.styl
# Plugin with compilation
stylus -u nib -c input.styl -o output.cssConfigure URL handling in imports and assets.
# Inline imported CSS files
stylus -U input.styl -o output.css
# Resolve relative URLs
stylus -r input.styl -o output.css
# Auto-prefix CSS properties
stylus -P input.styl -o output.css
# Auto-prefix with specific prefix
stylus -P webkit input.styl -o output.cssTools for debugging and development workflow.
# Print file dependencies
stylus -s input.styl
# Include CSS imports in output
stylus --include-css input.styl -o output.css
# Set custom output extension
stylus --ext .min.css input.styl -o build/
# Set custom output extension for processed files
stylus --out-ext .processed.css src/ -o build/Get help and version information.
# Display help
stylus -h
stylus --help
# Display version
stylus -V
stylus --version# All command-line options
stylus [options] [files...]
Options:
-w, --watch Watch for changes and recompile
-o, --out <dir> Output directory or file
-C, --css <src> [dest] Convert CSS to Stylus syntax
-I, --include <path> Include path for @import statements
-c, --compress Compress output CSS
-d, --compare Compare compiled output with existing file
-f, --firebug Include Firebug debug information
-l, --line-numbers Include line numbers in output CSS
-m, --sourcemap Generate source map (.map file)
-p, --print Print compiled CSS to stdout
-u, --use <plugin> Use the given plugin
-U, --inline Inline imported CSS files
-r, --resolve-url Resolve relative URLs in imports
-P, --prefix [prefix] Auto-prefix CSS properties
-s, --print-deps Print file dependencies to stdout
-h, --help Display help information
-V, --version Display version number
--include-css Include imported CSS in output
--ext <extension> Output file extension
--out-ext <extension> Output extension for processed files
--indent <string> Indentation string (for CSS conversion)# Basic compilation workflow
stylus main.styl -o main.css
# Development with watch mode
stylus -w -l -f src/styles.styl -o public/css/styles.css
# Production build with compression and source maps
stylus -c -m src/*.styl -o build/css/
# Using plugins and includes
stylus -u nib -u autoprefixer-stylus -I ./mixins -I ./variables main.styl -o main.css
# CSS to Stylus conversion
stylus --css legacy-styles.css modern-styles.styl
# Print dependencies for build tools
stylus -s main.styl > dependencies.txt
# Compare output (useful for testing)
stylus -d main.styl expected-output.css
# Multi-file compilation with custom extensions
stylus --ext .min.css --compress src/*.styl -o build/
# Complex build pipeline
stylus -u nib -I ./node_modules -I ./styles -c -m -P webkit src/main.styl -o dist/styles.css# Success
0 # Compilation successful
# Error codes
1 # General error (syntax error, file not found, etc.)
2 # Comparison failed (when using -d/--compare option){
"scripts": {
"css": "stylus src/styles.styl -o public/css/styles.css",
"css:watch": "stylus -w src/styles.styl -o public/css/styles.css",
"css:build": "stylus -c -m src/styles.styl -o dist/styles.css",
"css:deps": "stylus -s src/styles.styl"
}
}CSS_SRC = src/styles.styl
CSS_OUT = public/css/styles.css
css:
stylus $(CSS_SRC) -o $(CSS_OUT)
css-watch:
stylus -w $(CSS_SRC) -o $(CSS_OUT)
css-build:
stylus -c -m $(CSS_SRC) -o $(CSS_OUT)
css-deps:
stylus -s $(CSS_SRC)#!/bin/bash
# Build script with error handling
set -e
echo "Building Stylus files..."
# Compile with plugins and includes
stylus -u nib -I ./styles -c src/main.styl -o dist/main.css
# Generate source map
stylus -m src/main.styl -o dist/main.css
# Print dependencies
echo "Dependencies:"
stylus -s src/main.styl
echo "Build complete!"Install with Tessl CLI
npx tessl i tessl/npm-stylus