-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
45 lines (38 loc) · 1.23 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
var gulp = require("gulp");
var plugins = require("gulp-load-plugins")();
var browserify = require("browserify");
var source = require("vinyl-source-stream");
var path = require('path');
var connect = require("gulp-connect");
var paths = {
scripts: ["src/js/**/*"],
vendor: ["src/vendor/**/*"],
statics: ["src/*.html", "src/img/**/*", "src/css/**/*"]
};
gulp.task("vendor", function() {
gulp.src(paths.vendor)
.pipe(plugins.concat("vendor.js"))
.pipe(gulp.dest("www/vendor"));
});
gulp.task("statics", function(){
gulp.src(paths.statics, {base: "src"})
.pipe(gulp.dest("www"));
});
gulp.task("browserify", function() {
var bundleStream = browserify()
.add("./src/js/index.js")
.bundle();
bundleStream.on("error", function(error) {
plugins.util.log(plugins.util.colors.red(error));
this.end();
});
bundleStream.pipe(source("index.js"))
.pipe(gulp.dest("www/js"))
.pipe(connect.reload());
});
gulp.task("default", ["vendor", "statics", "browserify"], function() {
connect.server({ root: "www", livereload: true, port: 9000 });
gulp.watch(paths.scripts, ["vendor", "statics", "browserify"]);
gulp.watch(paths.vendor, ["vendor", "statics", "browserify"]);
gulp.watch(paths.statics, ["vendor", "statics", "browserify"]);
});