-
Notifications
You must be signed in to change notification settings - Fork 68
/
gulpfile.js
70 lines (53 loc) · 2.21 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
'use strict';
// -----------------------------------------------------------------------------
// Dependencies
// -----------------------------------------------------------------------------
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
// -----------------------------------------------------------------------------
// Configuration
// -----------------------------------------------------------------------------
var input = './assets/sass/**/*.scss';
var output = './assets/css';
var sassOptions = { outputStyle: 'expanded' }; //expanded
var autoprefixerOptions = { browsers: ['last 2 versions', '> 5%', 'Firefox ESR'] };
// -----------------------------------------------------------------------------
// Sass compilation
// -----------------------------------------------------------------------------
gulp.task('sass', function () {
return gulp.src(input)
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(concat('style.css'))
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest(output));
});
// -----------------------------------------------------------------------------
// Watchers
// -----------------------------------------------------------------------------
gulp.task('watch', function() {
return gulp
// Watch the input folder for change,
// and run `sass` task when something happens
.watch(input, ['sass'])
// When there is a change,
// log a message in the console
.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
// -----------------------------------------------------------------------------
// Production build
// -----------------------------------------------------------------------------
gulp.task('prod', function () {
return gulp
.src(input)
.pipe(sass((sassOptions)))
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest(output));
});
// -----------------------------------------------------------------------------
// Default task
// -----------------------------------------------------------------------------
gulp.task('default', ['sass', 'watch']);