-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgulpFile.js
103 lines (86 loc) · 2.42 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
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
95
96
97
98
99
100
101
102
103
var gulp = require("gulp")
var webserver = require("gulp-webserver")
var concat = require("gulp-concat")
var sass = require("gulp-sass")
var browserify = require("browserify")
var reactify= require("reactify")
var babelify = require("babelify")
var source = require("vinyl-source-stream")
var watchify = require("watchify")
var livereload = require("gulp-livereload")
var DEST = "build"
var src = {
webpages: "app/*.html",
css: "./app/css/*.scss",
images: "app/images/*.*"
}
gulp.task("default", ["watch"])
gulp.task("watch", ["build-app", "webserver"], function() {
gulp.watch(src.webpages, ["move-webpages"])
gulp.watch(src.css, ["css"])
gulp.watch(src.images, ["images"])
})
gulp.task("build-app", ["move-webpages", "bower-css", "bower-js", "fonts", "fonts-awesome", "css", "images", "react"])
gulp.task("move-webpages", function() {
return gulp.src(src.webpages)
.pipe(gulp.dest(DEST))
})
gulp.task('css', function () {
return gulp.src(src.css)
.pipe(sass())
.pipe(concat("main.css"))
.pipe(gulp.dest(DEST + "/css"))
})
gulp.task("images", function() {
return gulp.src(src.images)
.pipe(gulp.dest(DEST + "/images"))
})
gulp.task("bower-css", function() {
return gulp.src([
"app/bower/materialize/bin/materialize.css",
"app/bower/animate.css/animate.css",
"app/bower/font-awesome/css/font-awesome.css"
])
.pipe(concat("vendor.css"))
.pipe(gulp.dest(DEST + "/css"))
})
gulp.task("bower-js", function() {
return gulp.src([
'app/bower/jquery/dist/jquery.js',
'app/bower/materialize/dist/js/materialize.js'])
.pipe(concat('vendor.js'))
.pipe(gulp.dest(DEST + "/js"))
})
gulp.task("fonts", function() {
return gulp.src([
"app/bower/materialize/font/**/*"
])
.pipe(gulp.dest(DEST + "/font"))
})
gulp.task("fonts-awesome", function() {
return gulp.src([
"./app/bower/font-awesome/fonts/**.*"
])
.pipe(gulp.dest(DEST + "/fonts"))
})
gulp.task("webserver", ["build-app"], function() {
return gulp.src("build")
.pipe(webserver({
livereload: true
}))
})
gulp.task("react", function() {
var bundler;
var bundle = function() {
return bundler.bundle()
.pipe(source("main.js"))
.pipe(gulp.dest(DEST + "/js"))
.pipe(livereload())
}
bundler = browserify("./app/main.js", watchify.args)
bundler.transform(reactify)
bundler.transform(babelify)
bundler.on("update", bundle)
bundler = watchify(bundler)
return bundle()
})