-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.js
35 lines (28 loc) · 891 Bytes
/
build.js
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
31
32
33
34
35
async function build () {
const fs = require('fs');
const sass = require('sass');
const uglify = require('terser');
const sassOptions = {
file: process.cwd() + '/src/index.sass',
indentedSyntax: true,
outputStyle: 'compressed'
};
const sassResult = sass.renderSync(sassOptions);
const css = String(sassResult.css);
let findAndReplaceDOMText;
let findInNw;
try {
findAndReplaceDOMText = String(fs.readFileSync('./node_modules/findandreplacedomtext/src/findAndReplaceDOMText.js'));
findInNw = String(fs.readFileSync('./src/index.js'));
} catch (error) {
console.log(error);
}
findInNw = findInNw.replace('/* PLACEHOLDER */', css);
const result = await uglify.minify(findAndReplaceDOMText + findInNw);
try {
fs.writeFileSync('./dist/find-in-nw.js', result.code + '\n');
} catch (error) {
console.log(error);
}
}
build();