Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ Use path settings to customize where USWDS Compile looks for USWDS source and ou

### Additional settings

| Setting | Default | Description |
| --------------------------------- | -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sprite.projectIconsOnly` | `false` | Include _only_ the icons in `paths.src.projectIcons` in the icon sprite. |
| `settings.compile.browserslist` | `["> 2%", "last 2 versions", "IE 11", "not dead"]` | Define the [browserslist query](https://github.com/browserslist/browserslist?tab=readme-ov-file#queries) for CSS prefixes generated by [autoprefixer](https://github.com/postcss/autoprefixer). |
| `settings.compile.sassSourcemaps` | `true` | Include sourcemap when compiling SASS to CSS. |
| `settings.compile.sassDeprecationWarnings` | `false` | Show USWDS Sass deprecation warnings. When set to `true`, Sass will output deprecation warnings for USWDS code in the terminal during compilation. Deprecation warnings for non-USWDS Sass will output even when this value is set to `false`. |
| Setting | Default | Description |
| --------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `sprite.projectIconsOnly` | `false` | Include _only_ the icons in `paths.src.projectIcons` in the icon sprite. |
| `settings.compile.browserslist` | `["> 2%", "last 2 versions", "IE 11", "not dead"]` | Define the [browserslist query](https://github.com/browserslist/browserslist?tab=readme-ov-file#queries) for CSS prefixes generated by [autoprefixer](https://github.com/postcss/autoprefixer). |
| `settings.compile.sassSourcemaps` | `true` | Include sourcemap when compiling SASS to CSS. |
| `settings.compile.sassOptions` | `{quietDeps: true, style: "compressed"}` | Configure [sass-embedded options](https://sass-lang.com/documentation/js-api/interfaces/options/). By default SASS deprecation warnings arising from USWDS source are hidden and output CSS is minified. These options can be overridden and additional options specified. When `loadPaths` is defined, the paths are appended to those necessary for USWDS compilation. The `watch` script will also watch these directories for changes. |

### Functions

Expand Down
34 changes: 29 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@ let settings = {
},
browserslist: ["> 2%", "last 2 versions", "IE 11", "not dead"],
sassSourcemaps: true,
sassDeprecationWarnings: false,
/**
* @type {boolean | undefined}
* @deprecated Set `sassOptions.quietDeps` instead. */
sassDeprecationWarnings: undefined,
/**
* @type {import('sass-embedded').Options<"async">}
* @default
* {
* quietDeps: true,
* style: "compressed"
* }
*/
sassOptions: {},
},
sprite: {
width: 24,
Expand Down Expand Up @@ -190,7 +202,9 @@ function buildSass() {
grid: true,
overrideBrowserslist: settings.compile.browserslist,
}),
csso({ forceMediaMerge: false }),
...(settings.compile.sassOptions.style === "expanded"
? []
: [csso({ forceMediaMerge: false })]),
],
includes: [
// 1. local theme files
Expand All @@ -209,9 +223,16 @@ function buildSass() {
})
.pipe(
sass({
outputStyle: "compressed",
includePaths: buildSettings.includes,
quietDeps: !settings.compile.sassDeprecationWarnings,
style: "compressed",
...settings.compile.sassOptions,
loadPaths: [
...buildSettings.includes,
...(settings.compile.sassOptions.loadPaths ?? []),
Comment thread
mdmower-csnw marked this conversation as resolved.
],
quietDeps:
settings.compile.sassDeprecationWarnings !== undefined
? !settings.compile.sassDeprecationWarnings
: settings.compile.sassOptions.quietDeps ?? true,
}).on("error", handleError)
)
.pipe(replace(/\buswds @version\b/g, `based on uswds v${pkg}`))
Expand All @@ -228,6 +249,9 @@ function watchSass() {
[
`${paths.dist.theme}/**/*.scss`.replace("//", "/"),
`${paths.src.projectSass}/**/*.scss`.replace("//", "/"),
...(settings.compile.sassOptions.loadPaths ?? []).map((loadPath) =>
`${loadPath}/**/*.scss`.replace("//", "/")
),
],
buildSass
);
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"gulp-postcss": "9.0.1",
"gulp-rename": "2.0.0",
"gulp-replace": "1.1.4",
"gulp-sass": "5.1.0",
"gulp-sass": "6.0.1",
"gulp-svgstore": "9.0.0",
"postcss": "8.5.2",
"postcss-csso": "6.0.1",
Expand Down