Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fully tested!
  • Loading branch information
illusionfield committed Feb 18, 2025
1 parent 139f02f commit 165aa9c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions plugin/compile-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const userOptions = _getConfig(
);

let includePaths = [];

if('object' === typeof userOptions) {
if(Array.isArray(userOptions.includePaths)) {
includePaths = userOptions.includePaths;
Expand Down Expand Up @@ -46,16 +45,10 @@ class SassCompiler extends MultiFileCachingCompiler {
// The heuristic is that a file is an import (ie, is not itself processed as a root) if it matches _*.sass, _*.scss
// This can be overridden in either direction via an explicit `isImport` file option in api.addFiles.
isRoot(inputFile) {
// If the file is explicitly marked as an import, then it is not a root.
const fileOptions = inputFile.getFileOptions();
if(fileOptions.hasOwnProperty('isImport')) {
return !fileOptions.isImport;
}
// If the input file is a package file, it is not a root.
if(inputFile.isPackageFile()) {
return false;
}
// If the file is a partial (leading underscore), it is not a root.
const pathInPackage = inputFile.getPathInPackage();
const isPartial = hasUnderscore(pathInPackage);
return !isPartial;
Expand Down Expand Up @@ -205,7 +198,11 @@ class SassCompiler extends MultiFileCachingCompiler {
// Compile
let output;
try {
output = await sass.compileAsync(inputFile.getPathInPackage(), options);
let filePath = inputFile.getPathInPackage();
if(inputFile.getPackageName()) {
filePath = `${inputFile.getSourceRoot()}/${filePath}`;
}
output = await sass.compileAsync(filePath, options);
} catch(e) {
inputFile.error({
message: `Scss compiler ${e}\n`,
Expand Down Expand Up @@ -291,7 +288,6 @@ function _getConfig(...configFileNames) {
if(fileExists(configPath)) {
try {
return JSON.parse(fs.readFileSync(configPath, {encoding: 'utf8'}));
break;
} catch(e) {
console.warn(`[ SASS Compiler ] Custom config ignored (${configFileName}):\n - ${e}`);
if(debugMode) {
Expand Down

0 comments on commit 165aa9c

Please sign in to comment.