-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGulpfile.js
More file actions
64 lines (53 loc) · 1.51 KB
/
Gulpfile.js
File metadata and controls
64 lines (53 loc) · 1.51 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
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var concat = require('gulp-concat');
var browserSync = require('browser-sync').create()
var autoprefixer = require('gulp-autoprefixer');
var del = require('del');
var err = null; //Used for callback error tracking
var config = {
path: {
root: "./",
bower: "./assets/built/",
css: "./assets/css/**/*.css",
sass: "./assets/css/**/*.scss",
built: "./assets/built",
js: "./assets/js/*.js"
}
}
// Sass Compilation
gulp.task('css', function(cb) {
sass(config.path.sass, {style: 'expanded'})
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false,
remove: false
}))
.pipe(gulp.dest(config.path.built))
.on('error', sass.logError);
gulp.src(config.path.css)
.pipe(gulp.dest(config.path.built));
cb(err);
});
// Scripts Concatenation
gulp.task('scripts', function(cb) {
return gulp.src(config.path.js)
.pipe(concat('app.js'))
.pipe(gulp.dest(config.path.built));
cb(err);
});
// Run browsersync server
gulp.task('browsersync', ['css', 'scripts'], function (cb) {
browserSync.init({
server: config.path.root
});
cb(err);
});
// Watch tasks
gulp.task('watch', ['css', 'scripts','browsersync'], function() {
gulp.watch(config.path.sass, ['css']).on('change', browserSync.reload);
gulp.watch(config.path.js, ['scripts']).on('change', browserSync.reload);
gulp.watch(config.path.root + '/**/*.html').on('change', browserSync.reload);
});
//Default task
gulp.task('default', ['watch']);