3.1.0 • Published 7 months ago
@18f/identity-build-sass v3.1.0
@18f/identity-build-sass
Stylesheet compilation utility with reasonable defaults and fast performance.
Why use it?
- ⚡️ It's fast, since it uses native Dart Sass binary through
sass-embedded
, and the Rust-based Lightning CSS for autoprefixing and minification. - 💻 It includes a CLI, so it's easy to integrate with command-based build pipelines like NPM scripts or Makefile.
- 🚀 It has relevant defaults, to work out of the box with minimal or no additional configuration.
Default behavior includes:
- Optimizations enabled based on the
NODE_ENV
environment variable. - Autoprefixer configuration based on the current project's Browserslist configuration.
- Automatically adds
node_modules
as a loaded path for Sass compilation. - Output filenames derived from the input filenames (
main.css.scss
becomesmain.css
). - Automatically adds required load paths for
@18f/identity-design-system
and@uswds/uswds
.
Usage
CLI
Invoke the included build-sass
executable with the source files and any relevant command flags.
npx build-sass path/to/sass/*.scss
Flags:
--out-dir
: The output directory--watch
: Run in watch mode, recompiling files on change--load-path
: Include additional path in Sass path resolution--verbose
(-v
): Output verbose debugging details
API
buildFile
Compiles a given Sass file.
function buildFile(
file: string,
options: {
outDir: string,
optimize: boolean,
sassCompiler: SassAsyncCompiler,
...sassOptions: SassOptions<'sync'>,
},
): Promise<SassCompileResult>;
License
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request or issue, you are agreeing to comply with this waiver of copyright interest.