-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (56 loc) · 1.62 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"use strict"
var
del = require("del"),
sequence = require("run-sequence"),
gulp = require("gulp"),
browserify = require("browserify"),
babelify = require("babelify"),
source = require("vinyl-source-stream"),
connect = require("gulp-connect")
let buildDir = "build"
gulp.task("clean:dist", function() {
return del(["#{buildDir}/*", "!#{buildDir}", "!#{buildDir}/.git,{/**}"])
})
gulp.task("build:css", function() {
return gulp.src([
"./node_modules/angular-material/angular-material.min.css",
"./node_modules/angular-material/angular-material.layouts.min.css"
]).pipe(gulp.dest(`${buildDir}/css`))
})
gulp.task("build:html", function() {
return gulp.src(["./src/**/*.html"])
.pipe(gulp.dest(buildDir))
})
gulp.task("build:script", function() {
return browserify("./src/app.js")
.transform("babelify", { presets: ["es2015"]})
.bundle()
.pipe(source("dist.js"))
.pipe(gulp.dest(buildDir))
})
gulp.task("serve", function() {
connect.server({
root: buildDir,
port: process.env.PORT || 3000,
livereload: false
})
})
gulp.task("servedev", function() {
connect.server({
root: buildDir,
port: process.env.PORT || 3000,
livereload: true
})
})
gulp.task("build:prod", function(fn) {
sequence("clean:dist", "build:html", "build:css", "build:script", "serve", fn)
})
gulp.task("default", function(fn) {
sequence("clean:dist", "build:html", "build:css", "build:script", "watch", fn)
})
gulp.task('watch', function() {
var watcher = gulp.watch("src/**/*.html", ['build:html'])
watcher.on('change', function() {
connect.reload()
})
})