Skip to content

Commit

Permalink
refactor: code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jul 25, 2024
1 parent 8e9eaee commit 901e6b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
11 changes: 6 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ async function loader(content) {
const useSourceMap =
typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
// Use `legacy` for `node-sass` and `modern` for `dart-sass` and `sass-embedded`
const apiType = !implementation.compileStringAsync
? "legacy"
: typeof options.api === "undefined"
? "modern"
: options.api;
const apiType =
typeof implementation.compileStringAsync === "undefined"
? "legacy"
: typeof options.api === "undefined"
? "modern"
: options.api;
const sassOptions = await getSassOptions(
this,
options,
Expand Down
10 changes: 2 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,7 @@ function getWebpackResolver(
includePaths = [],
) {
const isModernSass =
implementation &&
(implementation.info.includes("dart-sass") ||
implementation.info.includes("sass-embedded"));
implementation && typeof implementation.compileStringAsync !== "undefined";
// We only have one difference with the built-in sass resolution logic and out resolution logic:
// First, we look at the files starting with `_`, then without `_` (i.e. `_name.sass`, `_name.scss`, `_name.css`, `name.sass`, `name.scss`, `name.css`),
// although `sass` look together by extensions (i.e. `_name.sass`/`name.sass`/`_name.scss`/`name.scss`/`_name.css`/`name.css`).
Expand Down Expand Up @@ -740,11 +738,7 @@ const sassModernCompilers = new WeakMap();
* @returns {Function}
*/
function getCompileFn(loaderContext, implementation, apiType) {
const isNewSass =
implementation.info.includes("dart-sass") ||
implementation.info.includes("sass-embedded");

if (isNewSass) {
if (typeof implementation.compileStringAsync !== "undefined") {
if (apiType === "modern") {
return (sassOptions) => {
const { data, ...rest } = sassOptions;
Expand Down

0 comments on commit 901e6b4

Please sign in to comment.