-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
52 lines (48 loc) · 1.61 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
var plumber = require("gulp-plumber");
var through = require("through2");
var newer = require("gulp-newer");
var babel = require("gulp-babel");
var watch = require("gulp-watch");
var gutil = require("gulp-util");
var gulp = require("gulp");
var debug = require("gulp-debug");
var rename = require("gulp-rename");
//var sourceRoot = "d:/dev/ng60-2/com.ibm.rdm.web/resources";
//var scripts = sourceRoot + "/artifact/AbstractResourceArtifactWidget.js";
var sourceRoot = "./src";
var scripts = sourceRoot + "/**/*.js";
//var dest = "d:/temp/ngjs/dng/TypeScriptHTMLApp1/resources";
//var scripts = "./src/**/*.js";
var dest = "./build";
var cwd = process.cwd();
gulp.task("default", ["build"]);
gulp.task("build", function () {
return gulp.src(scripts, {base: sourceRoot})
// .pipe(debug({title: "sources"}))
.pipe(watch(scripts))
.pipe(plumber({
errorHandler: function (err) {
gutil.log(err.stack);
}
}))
.pipe(newer({dest:dest, map: function(p) {
return p.replace(".js", ".ts");
}}))
.pipe(debug({title: "Compiling..."}))
.pipe(babel({
plugins: [
[cwd + "/node_modules/babel-plugin-transform-typescript-prepare", {
literal_only:true,
to_ts:true }
]
],
retainLines:true,
compact:false}))
.pipe(rename({extname: ".ts"}))
.pipe(gulp.dest(dest));
});
gulp.task("watch", ["build"], function (callback) {
watch(scripts, function () {
gulp.start("build");
});
});