-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
105 lines (87 loc) · 2.38 KB
/
gulpfile.js
File metadata and controls
105 lines (87 loc) · 2.38 KB
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
104
105
var gulp = require('gulp'),
browserify = require('gulp-browserify'),
babelify = require('babelify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream'),
watch = require('gulp-watch'),
browserSync = require('browser-sync'),
concat = require('gulp-concat'),
compass = require('gulp-compass'),
minify = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
del = require('del'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
gutil = require('gulp-util'),
debug = require('gulp-debug');
var onError = function (err) {
gutil.beep();
console.log(err);
};
gulp.task('build-dev', ['clean', 'js-dev', 'styles', 'bootstrap-fonts']);
gulp.task('build-style', ['clean-scss'], function(){
gulp.start('styles');
});
gulp.task('clean', function(){
del('./dest/**/*.*');
del('./app/assets/scss/*.*');
});
gulp.task('clean-scss', function(){
del('./dest/**/*.css');
del('./app/assets/scss/*.*');
});
gulp.task('js-dev', function() {
return gulp.src(['./app/app.js'])
.pipe(plumber({
errorHandler: onError
}))
.pipe(browserify({
transform: [babelify]
}))
.pipe(rename('app.js'))
.pipe(gulp.dest('./dest/js/'));
});
gulp.task('styles', [], function() {
return gulp.src(['app/**/*.scss'])
.pipe(plumber({
errorHandler: onError
}))
.pipe(concat('app.scss'))
.pipe(gulp.dest('dest/scss'))
.pipe(compass({
css: './dest/css',
sass: './dest/scss'
}))
.pipe(gulp.dest('./dest/css'));
});
gulp.task('bootstrap-fonts', function() {
return gulp.src(['assets/bootstrap/fonts/*.*'])
.pipe(plumber({
errorHandler: onError
}))
.pipe(gulp.dest('dest/assets/fonts/'));
});
gulp.task('reload', function(){
browserSync.reload();
});
gulp.task('watch', function(){
// Watch .scss and js files
gulp.watch(['app/**/*.scss','!app/assets/**/*.scss'], ['build-style']);
gulp.watch(['app/**/*.js'], ['js-dev']);
// Watching changed files
gulp.watch(['dest/**/*.css','dest/**/*.js'],['reload']);
});
// browser-sync task for starting the server.
gulp.task('browser-sync', ['watch'], function() {
browserSync({
open: true,
port: 3000,
server: {
baseDir: "./"
// middleware: [proxy(proxyOptions)]
}
});
});
gulp.task('default', ['build-dev'], function(){
gulp.start('browser-sync');
});