-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
79 lines (66 loc) · 1.92 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
var gulp = require('gulp')
var jade = require('gulp-jade')
var uglify = require('gulp-uglify')
var browserify = require("browserify")
var rename = require("gulp-rename")
var runSequence = require('run-sequence')
var mustache = require("gulp-mustache")
var babelify = require('babelify')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var sourcemaps = require('gulp-sourcemaps')
var livereload = require('gulp-livereload')
// Render .mustache [gulp mustache]
gulp.task("mustache", function() {
return gulp.src("./src/mustache/*")
.pipe(mustache('./src/json/data.json',{},{}))
.pipe(rename({
extname: ".html"
}))
.pipe(gulp.dest("./temp/"))
})
// Render index.jade [gulp jade]
gulp.task('jade', function() {
return gulp.src('./src/index.jade')
.pipe(jade())
.pipe(gulp.dest('./'))
})
// Build JS [gulp js]
gulp.task('js', function () {
return browserify({entries: './src/js/app.js', debug: true})
.transform("babelify", { presets: ["es2015"] })
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./assets/js'))
.pipe(livereload())
})
// Watch
gulp.task('watch', ['js'], function () {
livereload.listen()
gulp.watch('./src/js/*/**', ['js'])
})
// gulp.task('js', function() {
// browserify('src/js/app.js')
// .transform('babelify', { presets: ['env'] })
// .bundle()
// .pipe(fs.createWriteStream('assets/js/app.js'))
// .pump([
// gulp.src('assets/js/app.js'),
// uglify(),
// gulp.dest('./')
// ])
// .pipe(gulp.dest('assets/js'))
// return gulp.src('src/js/app.js')
// .pipe(babel({
// presets: ['env']
// }))
// .pipe(gulp.dest('assets/js'))
// })
// Do both [gulp]
gulp.task('default', function() {
runSequence('mustache','jade', 'js')
})