-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·31 lines (29 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
var gulp = require("gulp");
var fs = require("fs");
var package = require("./package.json");
var version = package.version.split(".").map((v) => parseInt(v) || 0);
gulp.task("bump", function(cb) {
version[2]++;
package.version = version.join(".");
fs.writeFileSync("./package.json", JSON.stringify(package, null, 2), { encoding: "utf8" });
cb();
});
gulp.task("modifyBundle", function(cb) {
var bundle = fs.readFileSync(`./dist/lib/${package.name}.bundle.js`, "utf8");
var bundle = bundle.replace("window, function()", `typeof(window) !== "undefined" ? window : typeof(global) !== "undefined" ? global : typeof(self) !== "undefined" ? self : undefined, function()`);
var bundle = bundle.replace("window,function()", `typeof(window) !== "undefined" ? window : typeof(global) !== "undefined" ? global : typeof(self) !== "undefined" ? self : undefined, function()`);
fs.writeFileSync(`./dist/lib/${package.name}.bundle.js`, bundle, { encoding: "utf8" });
cb();
});
gulp.task("package", gulp.series("bump", function() {
return gulp.src(["./package.json", "./README.md"])
.pipe(gulp.dest("dist/lib"));
}));
gulp.task("copyDTS", () => {
return gulp.src("./dts/**/*.d.ts")
.pipe(gulp.dest("dist/lib"));
});
gulp.task("copyWebpackExternalsFn", () => {
return gulp.src("./src/lib/webpackExternals.js")
.pipe(gulp.dest("dist/lib"));
});