-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
48 lines (41 loc) · 1.1 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
//Import modules
var gulp = require('gulp');
var sass = require('gulp-sass');
//Paths
var paths = {
styles: {
src: 'stylesheets/sass',
files: 'stylesheets/sass/**/*.scss',
dest: 'stylesheets/'
}
}
//Error handling
var displayError = function(error) {
var errorString = '[' + error.plugin + ']';
errorString += ' ' + error.message.replace("\n",'');
if(error.fileName)
errorString += ' in ' + error.fileName;
if(error.lineNumber)
errorString += ' on line ' + error.lineNumber;
console.error(errorString);
}
gulp.task('sass', function () {
gulp.src(paths.styles.files)
.pipe(sass({
outputStyle: 'compressed', //:nested, :compact, :expanded, :compressed
sourceComments: 'map',
includePaths : [paths.styles.src]
}))
.on('error', function(err){
displayError(err);
})
.pipe(gulp.dest(paths.styles.dest))
});
gulp.task('default', ['sass'], function() {
gulp.watch(paths.styles.files, ['sass'])
.on('change', function(evt) {
console.log(
'[watcher] File ' + evt.path.replace(/.*(?=sass)/,'') + ' was ' + evt.type + ', compiling...'
);
});
});