-
Notifications
You must be signed in to change notification settings - Fork 178
/
gulpfile.js
59 lines (52 loc) · 1.4 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
const gulp = require("gulp");
const rename = require("gulp-rename");
const ts = require("gulp-typescript");
const sass = require("gulp-sass");
const merge = require("merge2");
const tsProject = ts.createProject("./tsconfig.build.json");
const webpackStream = require("webpack-stream");
function buildStyles() {
return gulp
.src("./src/styles/**/*.scss")
.pipe(sass().on("error", sass.logError))
.pipe(gulp.dest("./lib/styles/css"));
}
// library
function copyStyles() {
return gulp
.src("./src/styles/**/*.scss")
.pipe(gulp.dest("./lib/styles/scss"));
}
// depends on copyStyles and buildStyles
function buildLib() {
const tsResult = tsProject.src().pipe(
tsProject({
declaration: true
})
);
return merge([
tsResult.dts.pipe(gulp.dest("lib/definitions")),
tsResult.js.pipe(gulp.dest("lib/js"))
]);
}
// demo
// removes the output configuration from the webpack.config.js file, otherwise it doesn't work.
function copyIndex() {
return gulp
.src("./demo/index.prod.html")
.pipe(rename("index.html"))
.pipe(gulp.dest("./docs"));
}
// depends on copyIndex
function buildDemo() {
return gulp
.src("demo/client.tsx")
.pipe(
webpackStream(
require("./webpack.config.demo.prod.js"),
require("webpack")
)
)
.pipe(gulp.dest("docs/"));
}
exports.build = gulp.series(buildStyles, copyStyles, copyIndex, buildLib, buildDemo);