Skip to content

Commit 901e6b4

Browse files
refactor: code
1 parent 8e9eaee commit 901e6b4

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ async function loader(content) {
3535
const useSourceMap =
3636
typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
3737
// Use `legacy` for `node-sass` and `modern` for `dart-sass` and `sass-embedded`
38-
const apiType = !implementation.compileStringAsync
39-
? "legacy"
40-
: typeof options.api === "undefined"
41-
? "modern"
42-
: options.api;
38+
const apiType =
39+
typeof implementation.compileStringAsync === "undefined"
40+
? "legacy"
41+
: typeof options.api === "undefined"
42+
? "modern"
43+
: options.api;
4344
const sassOptions = await getSassOptions(
4445
this,
4546
options,

src/utils.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,7 @@ function getWebpackResolver(
478478
includePaths = [],
479479
) {
480480
const isModernSass =
481-
implementation &&
482-
(implementation.info.includes("dart-sass") ||
483-
implementation.info.includes("sass-embedded"));
481+
implementation && typeof implementation.compileStringAsync !== "undefined";
484482
// We only have one difference with the built-in sass resolution logic and out resolution logic:
485483
// First, we look at the files starting with `_`, then without `_` (i.e. `_name.sass`, `_name.scss`, `_name.css`, `name.sass`, `name.scss`, `name.css`),
486484
// although `sass` look together by extensions (i.e. `_name.sass`/`name.sass`/`_name.scss`/`name.scss`/`_name.css`/`name.css`).
@@ -740,11 +738,7 @@ const sassModernCompilers = new WeakMap();
740738
* @returns {Function}
741739
*/
742740
function getCompileFn(loaderContext, implementation, apiType) {
743-
const isNewSass =
744-
implementation.info.includes("dart-sass") ||
745-
implementation.info.includes("sass-embedded");
746-
747-
if (isNewSass) {
741+
if (typeof implementation.compileStringAsync !== "undefined") {
748742
if (apiType === "modern") {
749743
return (sassOptions) => {
750744
const { data, ...rest } = sassOptions;

0 commit comments

Comments
 (0)