-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
52 lines (45 loc) · 1.22 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
var gulp = require('gulp')
, browserSync = require('browser-sync')
, rename = require('gulp-rename')
, minifyCSS = require('gulp-minify-css')
, uglify = require('gulp-uglify')
, browserify = require('browserify')
, watchify = require('watchify')
, source = require('vinyl-source-stream')
, buffer = require('vinyl-buffer')
, reload = browserSync.reload
gulp.task('serve', function() {
browserSync({
server: {
baseDir: "./app/"
}
})
gulp.watch(['./app/src/js/**/*.js'], ['scripts'])
gulp.watch(['./app/src/css/style.css'], ['css'])
gulp.watch('./app/**/*.{html,css}').on('change', reload)
})
gulp.task('css', function() {
return gulp.src('./app/src/css/style.css')
.pipe(minifyCSS())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./app/public/css'))
.pipe(reload({stream: true}))
})
var bundler = browserify({
entries: ['./app/src/js/app.js'],
cache: {},
packageCache: {},
fullPaths: true
})
var watcher = watchify(bundler)
gulp.task('scripts', function() {
watcher
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./app/public/js'))
.pipe(reload({stream: true}))
})
gulp.task('default', ['scripts', 'serve'])