This repository was archived by the owner on Jul 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
54 lines (47 loc) · 1.55 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// const babel = require('@babel/core');
const sass = require('sass');
const pug = require('pug');
const fs = require('fs').promises;
const path = require('path');
const { inlineSource } = require('inline-source');
(async () => {
try {
// folder scaffolding
console.log('Scaffolding folders...');
await Promise.all([
fs.mkdir('dist', { recursive: true }),
]);
// // Babel
// console.log('Transpiling JS...');
// let files = await fs.readdir('src/js');
// files = files.filter(file => path.extname(file).toLowerCase() === '.js');
// const transpiledFiles = await transpileJS(files);
// await writeJS(transpiledFiles);
// pug
console.log('Transpiling HTML...');
await fs.writeFile('dist/index.html', pug.renderFile('src/index.pug', {
filename: 'src/index.pug',
}));
// sass
console.log('Transpiling CSS...');
const CSS = sass.renderSync({
file: 'src/style/style.scss',
sourceMap: true,
outFile: 'src/style/style.css',
outputStyle: 'compressed',
});
await Promise.all([
fs.writeFile('src/style/style.css', CSS.css),
fs.writeFile('src/style/style.css.map', CSS.map),
]);
// inline-source
console.log('Inlining source...');
const html = await inlineSource(path.resolve('dist/index.html'), {
compress: true,
});
await fs.writeFile('dist/index.html', html);
console.log('✨ Done!');
} catch (err) {
console.log(err);
}
})();