1.0.2 • Published 4 years ago
@phanty/sass-bundler v1.0.2
sass-bundler
A quick and dirty npm package for bundling page-specific SASS/SCSS.
Installation
npm install --save-dev @phanty/sass-bundler
Usage
@import and @use statements in SASS must be preceeded by !bundler, e.g. @use "!bundler/_partial.scss".
For the bundler to recognize partials, their filename must be preceeded by _.
Outputs partials used by all SASS files to a single file.
Example
Input
a.scss
@use "!bundler/_partial1.scss"
#a{
color: red;
}b.scss
@use "!bundler/_partial1.scss"
#b{
color: green;
}_partial1.scss
span{
font-weight: bold;
}Compiles to
a.css
#a{
color: red;
}b.css
#b{
color: green;
}shared.css
span{
font-weight: bold;
}CLI
sass-bundler [command] [options]
Commands:
help- Print helpinit- Generate a default config file in current directorybuild- Build and bundle SASS/SCSS files. If sass-bundler.config.js isn't in the project root, uses default config.watch- Watch SASS/SCSS files for changes. If sass-bundler.config.js isn't in the project root, uses default config.
Options:
--config [string]- Path to config file--<CONFIG_ARG> [string]- Overwrite config argument
API
class Bundler(config?)
.buildAll()- Builds and bundles all SCSS/SASS files according toconfig.watch()- Watches files for changes. Incrementally compiles.
Configuration
sassDir: [string]-./sass- Path to the SASS/SCSS directoryoutDir: [string]- Default:./build- Path to the output directoryverbose: [boolean]- Default:false- If true, prints which files have been compiledsharedPath: [string]- Default:./build/shared.css- Path to the file where to output the shared css