-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
40 lines (37 loc) · 1.76 KB
/
gulpfile.babel.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
import gulp from "gulp";
import path from "path";
import paths from "vinyl-paths";
import del from "del";
import run from "run-sequence";
import jasmine from "gulp-jasmine";
import reporters from "jasmine-reporters";
import typescript from "typescript";
import gts from "gulp-typescript";
import sass from "gulp-sass";
import merge from "merge2";
import sourcemaps from "gulp-sourcemaps";
import tsconfig from "./tsconfig.json";
import pkconfig from "./package.json";
const sassOptions = {
importer: url => ({ file: url.startsWith("~") ? path.resolve("node_modules", url.substr(1)) : url })
};
const typescriptSources = [ tsconfig.compilerOptions.rootDir + "/**/*.ts" ];
const htmlSources = [ tsconfig.compilerOptions.rootDir + "/**/*.html" ];
const scssSources = [ tsconfig.compilerOptions.rootDir + "/**/*.scss" ];
const output = tsconfig.compilerOptions.outDir;
const testSuites = [ "dist/test/**/*.js" ];
const clean = [ output ];
const tsc = gts(Object.assign({ typescript: typescript }, tsconfig.compilerOptions));
gulp.task("clean", done => gulp.src(clean).pipe(paths(del)));
gulp.task("build-typescript", done => {
let stream = gulp.src(typescriptSources).pipe(sourcemaps.init()).pipe(tsc);
return merge([
stream.js.pipe(sourcemaps.write(".", { mapSources: sourcePath => "../" + sourcePath })).pipe(gulp.dest(output)),
stream.dts.pipe(gulp.dest(output))
]);
});
gulp.task("build-scss", done => gulp.src(scssSources).pipe(sass(sassOptions)).pipe(gulp.dest(output)));
gulp.task("build-html", done => gulp.src(htmlSources).pipe(gulp.dest(output)));
gulp.task("build", done => run("clean", [ "build-typescript", "build-scss", "build-html" ], done));
gulp.task("test", [ "build" ], done => gulp.src(testSuites).pipe(jasmine()));
gulp.task("default", [ "test" ]);