Skip to content

Commit

Permalink
Implement sass --embedded in pure JS mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Oct 28, 2024
1 parent 6d60eea commit 75f77ee
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/src/compiler-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export const compilerCommand = (() => {
`sass-embedded-${platform}-${arch}/dart-sass/src/sass.snapshot`
),
];
} catch (ignored) {
// ignored
} catch (e) {
if (!(isErrnoException(e) && e.code === 'MODULE_NOT_FOUND')) {
throw e;
}
}

try {
Expand All @@ -70,10 +72,21 @@ export const compilerCommand = (() => {
}
}

try {
return [
process.execPath,
p.join(p.dirname(require.resolve('sass')), 'sass.js'),
];
} catch (e: unknown) {
if (!(isErrnoException(e) && e.code === 'MODULE_NOT_FOUND')) {
throw e;
}
}

throw new Error(
"Embedded Dart Sass couldn't find the embedded compiler executable. " +
'Please make sure the optional dependency ' +
`sass-embedded-${platform}-${arch} is installed in ` +
`sass-embedded-${platform}-${arch} or sass is installed in ` +
'node_modules.'
);
})();

0 comments on commit 75f77ee

Please sign in to comment.