forked from netbeast/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (56 loc) · 1.65 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
'use strict'
var gulp = require('gulp')
var sourcemaps = require('gulp-sourcemaps')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var browserify = require('browserify')
var nodemon = require('gulp-nodemon')
var sass = require('gulp-sass')
var minify = require('gulp-minify-css')
var livereload = require('gulp-livereload')
gulp.task('default', ['serve'], function () {
livereload.listen()
gulp.watch('./web/assets/css/**', ['sass'])
gulp.watch('./web/assets/js/**', ['browserify'])
gulp.watch('./web/views/**/*.html', function (files) {
livereload.changed(files)
})
})
gulp.task('serve', function () {
nodemon({
script: './index.js',
ignore: ['test/*', '.gulpfile', '.git', '.sandbox/*', '*.md', '*.txt', 'web/*'],
env: { 'ENV': 'development' }
})
})
gulp.task('build', ['sass', 'browserify'])
gulp.task('sass', function () {
gulp.src('./web/assets/css/style.scss')
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(minify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/dist/css'))
.pipe(livereload())
})
gulp.task('browserify', function () {
// set up the browserify instance on a task basis
var bundler = browserify({
entries: './web/assets/js/index.js',
debug: true
})
return bundler.bundle()
.on('error', function (err) {
// print the error (can replace with gulp-util)
console.log(err.message)
// end this stream
this.emit('end')
})
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/dist/js/'))
.pipe(livereload())
})