Watch inlined files

This commit is contained in:
Samuel Elliott 2019-03-17 08:15:52 +00:00
parent 6a38e8ec47
commit d4ed8ad240
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 15 additions and 5 deletions

View File

@ -87,7 +87,7 @@ class Comms {
});
});
const sassImporter = async (context, url, prev) => {
const sassImporter = async (context, url, prev, inlinedFiles) => {
let file = path.resolve(path.dirname(prev), url);
const scss = await FileUtils.readFile(file).catch(err => FileUtils.readFile(file += '.scss'));
@ -95,7 +95,10 @@ class Comms {
const result = await postcss([postcssUrl({url: 'inline', encodeType: 'base64', optimizeSvgEncode: true})])
.process(scss, {from: file, syntax: postcssScss});
console.log('Processed', file, result);
for (const message of result.messages) {
if (message.type !== 'dependency') continue;
inlinedFiles.push(message.file);
}
return {file, contents: result.css};
};
@ -106,13 +109,16 @@ class Comms {
options.path = undefined;
}
const inlinedFiles = [];
options.importer = function (url, prev, done) {
sassImporter(this, url, prev).then(done, done);
sassImporter(this, url, prev, inlinedFiles).then(done, done);
};
sass.render(options, (err, result) => {
if (err) event.reject(err);
else event.reply(result);
if (err) return event.reject(err);
result.stats.includedFiles = result.stats.includedFiles.concat(inlinedFiles);
event.reply(result);
});
});

View File

@ -35,3 +35,7 @@ $index: 0;
$index: $index + 1;
}
.bd-scroller {
background-image: url('icon.svg');
}