Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.9.0 - Update dependencies #202

Merged
merged 2 commits into from
Jan 26, 2025
Merged
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
5 changes: 3 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ jobs:
strategy:
matrix:
node-version:
- 14.x
- 18.x
- 19.x
- 20.x
- 22.x
- 23.x
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
faucet-pipeline-sass version history
==================================

v1.9.0
------

_2025-01-26_

* Maintenance release to update dependencies
* Internally switched to the new `compile` API

v1.8.0
------

Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function makeBundler(config, assetManager, { browsers, compact, sourcemaps } = {
return renderSass().
then(autoprefix).
then(result => {
previouslyIncludedFiles = result.stats.includedFiles.
map(filepath => path.normalize(filepath));
previouslyIncludedFiles = (result.loadedUrls ?? []).
map(filepath => path.normalize(filepath.toString()));

let options = {};
if(fingerprint !== undefined) {
Expand Down
44 changes: 25 additions & 19 deletions lib/make-sass-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,50 @@ let sass = require("sass");

module.exports = function(inputFileName, target, assetManager, sourcemaps, compact) {
let sassOptions = {
file: inputFileName,
outputStyle: compact ? "compressed" : "expanded",
includePaths: [assetManager.packagesDir],
style: compact ? "compressed" : "expanded",
loadPaths: [assetManager.packagesDir],
sourceMap: sourcemaps,
sourceMapEmbed: sourcemaps,
outFile: target,
functions: {
"asset-url($assetName)": assetName => {
let name = assetName.getValue();
"asset-url($assetName)": args => {
let name = args[0].text;
let mappedAssetName = assetManager.manifest.get(name);
if(!mappedAssetName) {
throw new Error(`${name} could not be found`);
}

/* eslint-disable indent */
return mappedAssetName ?
new sass.types.String(`url("${mappedAssetName}")`) :
new sass.types.Error(`${name} could not be found`);
/* eslint-enable indent */
return new sass.SassString(`url("${mappedAssetName}")`, {
quotes: false
});
}
}
};

return _ => renderSass(sassOptions);
return _ => renderSass(inputFileName, sassOptions);
};

// promisified version of sass.render
function renderSass(options) {
function renderSass(inputFileName, options) {
return new Promise((resolve, reject) => {
try {
// using synchronous rendering because it is faster
let result = sass.renderSync(options);
result.css = fixEOF(result.css);
let result = sass.compile(inputFileName, options);
if(result.sourceMap) {
result.css = embedSourcemap(result);
}
// every file shall end with a newline. sass doesn't seem to care
result.css = `${result.css}\n`;
resolve(result);
} catch(err) {
reject(err);
}
});
}

// every file shall end with a newline. sass doesn't seem to care.
function fixEOF(buf) {
return Buffer.concat([buf, Buffer.from("\n")]);
// the new API can't embed sourcemaps
// https://github.com/sass/dart-sass/issues/1594#issuecomment-1013208452
function embedSourcemap(result) {
const sm = JSON.stringify(result.sourceMap);
const smBase64 = Buffer.from(sm, "utf8").toString("base64");
const smComment = `/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${smBase64}*/`; /* eslint-disable-line max-len */
return `${result.css}\n${smComment}`;
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "faucet-pipeline-sass",
"version": "1.8.0",
"version": "1.9.0",
"description": "Sass for faucet-pipeline",
"main": "lib/index.js",
"scripts": {
Expand All @@ -19,13 +19,13 @@
},
"homepage": "https://www.faucet-pipeline.org",
"engines": {
"node": ">= 14"
"node": ">= 18"
},
"dependencies": {
"autoprefixer": "~10.4.5",
"autoprefixer": "~10.4.20",
"faucet-pipeline-core": "^2.0.0",
"postcss": "~8.4.12",
"sass": "~1.63.3"
"postcss": "~8.5.1",
"sass": "~1.83.4"
},
"devDependencies": {
"eslint-config-fnd": "^1.13.0",
Expand Down
2 changes: 1 addition & 1 deletion test/test_import_css/src/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "./lib";
@use "./lib";

.bar {
background: red;
Expand Down
2 changes: 1 addition & 1 deletion test/test_import_scss/src/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "./lib";
@use "./lib";

.bar {
background: red;
Expand Down
6 changes: 1 addition & 5 deletions test/test_sourcemap/expected.css.map

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

Loading