forked from yoichiro/mindmap_tab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
94 lines (83 loc) · 2.28 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// generated on 2016-04-12 using generator-chrome-extension 0.5.1
import gulp from "gulp";
import gulpLoadPlugins from "gulp-load-plugins";
import del from "del";
import runSequence from "run-sequence";
import browserify from "browserify";
import source from "vinyl-source-stream";
import babelify from "babelify";
const $ = gulpLoadPlugins();
function lint(files, options) {
return () => {
return gulp.src(files)
.pipe($.eslint(options))
.pipe($.eslint.format());
};
}
gulp.task("extras", () => {
return gulp.src([
"app/*.*",
"app/_locales/**",
"!app/scripts.babel",
"app/scripts/bundle.js",
"app/scripts/background.js",
"app/bower_components/jquery/dist/jquery.min.js",
"app/bower_components/jcanvas/jcanvas.js",
"app/bower_components/bootstrap/dist/js/bootstrap.min.js",
"app/bower_components/bootstrap/dist/css/bootstrap.min.css",
"app/bower_components/responsive-bootstrap-toolkit/dist/bootstrap-toolkit.min.js",
"app/libs/ace/*.js",
"app/*.json",
"app/*.html",
"app/styles/*.css",
"app/images/*.ico",
"app/images/*.png"
], {
base: "app",
dot: true
}).pipe(gulp.dest("dist"));
});
gulp.task("lint", lint("app/scripts.babel/**/*.js", {
env: {
es6: true
}
}));
gulp.task("babel", () => {
return gulp.src("app/scripts.babel/**/*.js")
.pipe($.babel({
presets: ["es2015"]
}))
.pipe(gulp.dest("app/scripts"));
});
gulp.task("browserify", () => {
return browserify({
entries: [
"app/scripts/newtab.js"
],
extensions: [
".jsx"
]
}).transform(babelify, {
presets: ["es2015", "react"]
}).bundle()
.pipe(source("bundle.js"))
.pipe(gulp.dest("app/scripts"));
});
gulp.task("serviceWorker", () => {
gulp.src("app/scripts/service_worker*.js")
.pipe(gulp.dest("app"));
});
gulp.task("package", function () {
const manifest = require("./dist/manifest.json");
return gulp.src("dist/**")
.pipe($.zip("mindmap_tab-" + manifest.version + ".zip"))
.pipe(gulp.dest("package"));
});
gulp.task("clean", del.bind(null, [".tmp", "dist"]));
gulp.task("build", (cb) => {
runSequence(
"lint", "babel", "serviceWorker", "browserify", "extras", "package", cb);
});
gulp.task("default", ["clean"], cb => {
runSequence("build", cb);
});