Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vdimir committed Apr 18, 2021
1 parent fa8cbb6 commit 3e984e4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@ export default function plugin(options = {}) {
if (options.output && isString(options.output)) {
fs.mkdirSync(dirname(options.output), { recursive: true });

let totalSourcesUsed = 0;
let fd = fs.openSync(options.output, 'w')
for (let id in generatedData) {
if (generatedData[id]['epoch'] < epoch) {
continue;
}
totalSourcesUsed++;
fs.appendFileSync(fd, generatedData[id]['css'])
}
fs.closeSync(fd)

let totalSourcesUsedMsg = totalSourcesUsed > 1 ? `${totalSourcesUsed} sources` : `one source`;
console.log(`rollup-plugin-less: styles from ${totalSourcesUsedMsg} are written into '${options.output}'`)
}
},
async transform(code, id) {
Expand All @@ -72,6 +77,8 @@ export default function plugin(options = {}) {
if (options.output && isFunc(options.output)) {
css = await options.output(css, id);
}
console.log(`rollup-plugin-less: compile style '${id}'`)

generatedData[id] = {epoch, css}

let exportCode;
Expand Down

0 comments on commit 3e984e4

Please sign in to comment.