-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (66 loc) · 2.06 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
minifyCSS = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
watch = require('gulp-watch'),
rename = require('gulp-rename'),
copy = require('gulp-copy'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
nodemon = require('gulp-nodemon'),
buffer = require('vinyl-buffer'),
del = require('del'),
gulpSequence = require('gulp-sequence');
var srcRoot = "app/assets",
distRoot = "public/assets";
gulp.task('sass', function() {
gulp.src(srcRoot + '/stylesheets/style.scss')
.pipe(sass().on('error', sass.logError))
.pipe(minifyCSS())
.pipe(rename('style.min.css'))
.pipe(gulp.dest(distRoot + '/css'));
});
gulp.task('browserify', function () {
console.log("testing");
return browserify(srcRoot + '/javascripts/app.js')
.bundle()
//Pass desired output filename to vinyl-source-stream
.pipe(source('bundle.js'))
// Start piping stream to tasks!
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(distRoot + '/javascripts'));
});
gulp.task('compress', function() {
return gulp.src(distRoot + '/javascripts/**/*.js')
.pipe(uglify())
.pipe(gulp.dest( distRoot +'/javascripts'));
});
gulp.task('demon', function () {
nodemon({
script: 'start.js'
, ext: 'js html'
, env: { 'NODE_ENV': 'development' }
})
})
gulp.task('clean', function (cb) {
del([distRoot], cb);
});
gulp.task('copyImg', function() {
return gulp.src(srcRoot + '/images/**').pipe(gulp.dest(distRoot + '/images'));
})
gulp.task('copyHTML', function() {
return gulp.src(srcRoot + '/javascripts/**/*.html').pipe(gulp.dest(distRoot + '/views'));
})
gulp.task('watch', function () {
gulp.watch(srcRoot + '/javascripts/**/*.js', ['browserify']);
gulp.watch(srcRoot + '/stylesheets/**/*.scss', ['sass']);
});
// gulp.task( 'default', ['sass', 'copyImg', 'copyHTML', 'browserify'], ['demon', 'watch'] );
gulp.task('default', function (cb) {
gulpSequence(['sass', 'copyImg', 'copyHTML', 'browserify'],['demon', 'watch'], function(){
console.log("Running");
cb();
})
// gulpSequence makes this happen
});