-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
44 lines (35 loc) · 1.15 KB
/
gulpfile.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
const gulp = require("gulp");
const postcss = require("postcss");
const path = require("path");
const fs = require("fs");
const config = require("./config.js");
const router = require("./client/router.js");
const { bundlerPromise } = require("./bundler/bundler.js");
//
// framework compiler
//
gulp.task("build", end => {
const outputDir = router.dist;
const cssFileDir = path.join(outputDir, "index.css");
const jsFileDir = path.join(outputDir, "index.js");
const htmlFileDir = path.join(outputDir, "index.html");
bundlerPromise(router)
.then(() => {
// concat files ready!
// parse css
let cssFile = fs.readFileSync(cssFileDir, "UTF-8");
return postcss([
require("autoprefixer"),
]).process(cssFile);
})
.then(result => {
// css parsed!
fs.writeFileSync(cssFileDir, result.css, "UTF-8");
console.log("Compiled success!!");
console.log(outputDir);
end();
})
.catch(err => {
end();
});
});