@18f/identity-build-sass
Advanced tools
Comparing version 3.0.0 to 3.1.0
12
cli.js
@@ -17,2 +17,4 @@ #!/usr/bin/env node | ||
/** @typedef {import('./').BuildOptions} BuildOptions */ | ||
/** @typedef {import('node:child_process').ChildProcess} ChildProcess */ | ||
/** @typedef {import('sass-embedded').AsyncCompiler & { process: ChildProcess}} SassAsyncCompiler */ | ||
@@ -28,6 +30,7 @@ const env = process.env.NODE_ENV || process.env.RAILS_ENV || 'development'; | ||
'load-path': { type: 'string', multiple: true, default: [] }, | ||
verbose: { type: 'boolean', short: 'v' }, | ||
}, | ||
}); | ||
const { watch: isWatching, 'out-dir': outDir, 'load-path': loadPaths = [] } = flags; | ||
const { watch: isWatching, 'out-dir': outDir, 'load-path': loadPaths = [], verbose } = flags; | ||
loadPaths.push(...getDefaultLoadPaths()); | ||
@@ -67,2 +70,6 @@ | ||
function build(files) { | ||
if (verbose) { | ||
console.log('Building files', files); | ||
} | ||
return Promise.all( | ||
@@ -81,3 +88,4 @@ files.map(async (file) => { | ||
if (isWatching && isSassException(error)) { | ||
watchOnce(getErrorSassStackPaths(error.sassStack), () => build(files)); | ||
const { spawnfile } = /** @type {SassAsyncCompiler} */ (sassCompiler).process; | ||
watchOnce(getErrorSassStackPaths(error.sassStack, spawnfile), () => build(files)); | ||
} else { | ||
@@ -84,0 +92,0 @@ throw error; |
@@ -0,1 +1,3 @@ | ||
import { dirname, relative, resolve } from 'path'; | ||
/** | ||
@@ -7,13 +9,8 @@ * Returns all file paths contained in the given Sass stack trace. | ||
* getErrorSassStackPaths( | ||
* 'node_modules/@18f/identity-design-system/dist/assets/scss/uswds/core/_functions.scss 35:8 divide()\n' + | ||
* 'node_modules/@18f/identity-design-system/dist/assets/scss/uswds/core/mixins/_icon.scss 77:12 add-color-icon()\n' + | ||
* 'app/assets/stylesheets/components/_alert.scss 13:5 @import\n' + | ||
* 'app/assets/stylesheets/components/all.scss 3:9 @import\n' + | ||
* 'app/assets/stylesheets/application.css.scss 7:9 root stylesheet\n', | ||
* '../../../../app/assets/stylesheets/design-system-waiting-room.scss 31:2 @forward\n' + | ||
* '../../../../app/assets/stylesheets/application.css.scss 4:1 root stylesheet\n', | ||
* 'node_modules/sass-embedded-darwin-arm64/dart-sass/src/dart', | ||
* ); | ||
* // [ | ||
* // 'node_modules/@18f/identity-design-system/dist/assets/scss/uswds/core/_functions.scss', | ||
* // 'node_modules/@18f/identity-design-system/dist/assets/scss/uswds/core/mixins/_icon.scss', | ||
* // 'app/assets/stylesheets/components/_alert.scss', | ||
* // 'app/assets/stylesheets/components/all.scss', | ||
* // 'app/assets/stylesheets/design-system-waiting-room.scss', | ||
* // 'app/assets/stylesheets/application.css.scss', | ||
@@ -24,11 +21,12 @@ * // ] | ||
* @param {string} sassStack Sass stack trace (see example). | ||
* @param {string} relativeFrom File from which to resolve relative paths from Sass stack trace. | ||
* | ||
* @return {string[]} Array of file paths. | ||
*/ | ||
const getErrorSassStackPaths = (sassStack) => | ||
const getErrorSassStackPaths = (sassStack, relativeFrom) => | ||
sassStack | ||
.split(/\.scss \d+:\d+\s+.+?\n/) | ||
.filter(Boolean) | ||
.map((basename) => `${basename}.scss`); | ||
.map((basename) => relative('.', resolve(dirname(relativeFrom), `${basename}.scss`))); | ||
export default getErrorSassStackPaths; |
@@ -29,3 +29,3 @@ import { basename, join, dirname } from 'node:path'; | ||
* @param {string} file File to build. | ||
* @param {BuildOptions & SyncSassOptions} options Build options. | ||
* @param {Partial<BuildOptions> & SyncSassOptions} options Build options. | ||
* | ||
@@ -32,0 +32,0 @@ * @return {Promise<CompileResult>} |
{ | ||
"name": "@18f/identity-build-sass", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"private": false, | ||
@@ -11,7 +11,7 @@ "description": "Stylesheet compilation utility with reasonable defaults and fast performance.", | ||
"bin": { | ||
"build-sass": "./cli.js" | ||
"build-sass": "cli.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/18f/identity-idp.git", | ||
"url": "git+https://github.com/18f/identity-idp.git", | ||
"directory": "app/javascript/packages/build-sass" | ||
@@ -25,2 +25,5 @@ }, | ||
], | ||
"exports": { | ||
".": "./index.js" | ||
}, | ||
"license": "CC0-1.0", | ||
@@ -34,6 +37,7 @@ "bugs": { | ||
"browserslist": "^4.22.3", | ||
"chokidar": "^3.5.3", | ||
"chokidar": "^3.6.0", | ||
"lightningcss": "^1.23.0", | ||
"sass-embedded": "^1.70.0" | ||
} | ||
}, | ||
"sideEffects": false | ||
} |
@@ -34,2 +34,3 @@ # `@18f/identity-build-sass` | ||
- `--load-path`: Include additional path in Sass path resolution | ||
- `--verbose` (`-v`): Output verbose debugging details | ||
@@ -36,0 +37,0 @@ ### API |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11381
192
59
Updatedchokidar@^3.6.0