-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
53 lines (49 loc) · 1.39 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer');
var sassPaths = [
'node_modules/foundation-sites/scss',
'node_modules/motion-ui/src'
];
function sassDev() {
return sass({ dev: true });
}
function sassProd() {
return sass();
}
function sass(options) {
var dev = options && options.dev;
var sassOptions = {
includePaths: sassPaths
};
var renamePipe;
if (dev) {
renamePipe = $.util.noop();
} else {
sassOptions.outputStyle = 'compressed';
renamePipe = $.rename({
suffix: '.min'
});
}
return gulp.src('src/scss/app.scss')
.pipe($.sass(sassOptions).on('error', $.sass.logError))
.pipe($.postcss([
autoprefixer({ browsers: ['last 2 versions', 'ie >= 9'] })
]))
.pipe(renamePipe)
.pipe(gulp.dest('css'))
.pipe(browserSync.stream());
}
function serve() {
browserSync.init({
server: "./"
});
gulp.watch("src/scss//*.scss", sass);
gulp.watch(".//*.html").on('change', browserSync.reload);
}
gulp.task('sassDev', sassDev);
gulp.task('sassProd', sassProd);
gulp.task('sass', gulp.series('sassDev', 'sassProd'));
gulp.task('serve', gulp.series('sass', serve));
gulp.task('default', gulp.series('sass', serve));