forked from darkreader/darkreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle-css.js
More file actions
30 lines (26 loc) · 1001 Bytes
/
Copy pathbundle-css.js
File metadata and controls
30 lines (26 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require('fs-extra');
const less = require('less');
const path = require('path');
const {getDestDir} = require('./paths');
function getLessFiles({production}) {
const dir = getDestDir({production});
return {
'src/ui/devtools/style.less': `${dir}/ui/devtools/style.css`,
'src/ui/popup/style.less': `${dir}/ui/popup/style.css`,
'src/ui/stylesheet-editor/style.less': `${dir}/ui/stylesheet-editor/style.css`,
};
}
async function bundleCSSEntry({src, dest}) {
const srcDir = path.join(process.cwd(), path.dirname(src));
const input = await fs.readFile(src, {encoding: 'utf8'});
const output = await less.render(input, {paths: [srcDir]});
const {css} = output;
await fs.outputFile(dest, css, {encoding: 'utf8'});
}
async function bundleCSS({production}) {
const files = getLessFiles({production});
for (const [src, dest] of Object.entries(files)) {
await bundleCSSEntry({src, dest});
}
}
module.exports = bundleCSS;