Skip to content

Commit

Permalink
Add debug outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
kentaroi committed Jun 24, 2023
1 parent b2d554c commit afc1997
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/eleventy-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,52 @@ const eleventySass = function(eleventyConfig, userOptions = {}) {


const compileWithCache = async function(inputContent, inputPath, bypass) {
if (bypass)
debugDev("%o compileWithCache called (bypass: %o)", inputPath, bypass);
if (bypass) {
debugDev("%o compileWithCache ignored the call (eleventy-sass doesn't support computed data)", inputPath);
return () => inputContent;
}

let cache = compileCache.get(inputPath);
if (cache !== undefined) {
if (cache === null)
if (cache === null) {
debugDev("%o compileWithCache is returning cached undefined", inputPath);
return undefined;
}

debugDev("%o compileWithCache is returning a cached value", inputPath);
return () => cache;
}

let css = await compile.call(this, inputContent, inputPath, sassOptions, this.config, postcss);
if (css === undefined) {
compileCache.set(inputPath, null);
debugDev("%o compileWithCache is returning undefined", inputPath);
return undefined;
}

compileCache.set(inputPath, css);

debugDev("%o compileWithCache is returning a compiled value", inputPath);
return async (data) => {
return css;
};
};

const compileWithoutCache = async function(inputContent, inputPath, bypass) {
if (bypass)
debugDev("%o compileWithoutCache called (bypass: %o)", inputPath, bypass);
if (bypass) {
debugDev("%o compileWithoutCache ignored the call (eleventy-sass doesn't support computed data)", inputPath);
return () => inputContent;
}

let css = await compile.call(this, inputContent, inputPath, sassOptions, this.config, postcss);
if (css === undefined)
if (css === undefined) {
debugDev("%o compileWithoutCache is returning undefined", inputPath);
return undefined;
}

debugDev("%o compileWithoutCache is returning a compiled value", inputPath);
return async (data) => {
return css;
};
Expand Down

0 comments on commit afc1997

Please sign in to comment.