-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (55 loc) · 1.39 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const fs = require("fs");
const execSync = require("child_process").execSync;
const prettyBytes = require("pretty-bytes");
const gzipSize = require("gzip-size");
const gulp = require("gulp");
const exec = (command, extraEnv) =>
execSync(command, {
stdio: "inherit",
env: Object.assign({}, process.env, extraEnv)
});
gulp.task("build-es", done => {
console.log("\nBuilding ES modules ...");
exec("babel src -d es --ignore *.test.js", {
BABEL_ENV: "es"
});
done();
});
gulp.task("build-commonjs", done => {
console.log("Building CommonJS modules ...");
exec("babel src -d lib --ignore *.test.js", {
BABEL_ENV: "cjs"
});
done();
});
gulp.task("build-umd-dev", done => {
console.log("\nBuilding UMD ...");
exec("rollup -c -f umd -o umd/spectre-react-lib.js", {
BABEL_ENV: "umd",
NODE_ENV: "development"
});
done();
});
gulp.task("build-umd-prod", done => {
console.log("\nBuilding UMD min.js ...");
exec("rollup -c -f umd -o umd/spectre-react-lib.min.js", {
BABEL_ENV: "umd",
NODE_ENV: "production"
});
done();
});
gulp.task("umd-size", done => {
const size = gzipSize.sync(fs.readFileSync("umd/spectre-react-lib.min.js"));
console.log("\ngzipped, the UMD build is %s", prettyBytes(size));
done();
});
gulp.task(
"build",
gulp.series(
"build-es",
"build-commonjs",
"build-umd-dev",
"build-umd-prod",
"umd-size"
)
);