-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (48 loc) · 1.43 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var cleanCSS = require('gulp-clean-css');
var exec = require('child_process').exec;
gulp.task('webpack', function(cb) {
exec('npm run webpack', function(err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('sass', function () {
return gulp.src('./src/scss/**/*.scss')
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.stream())
});
gulp.task('browser-sync', function() {
browserSync.init({
server: './public',
notify: false,
open: false
})
});
gulp.task('sass:minify', function () {
return gulp.src('./src/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.stream())
});
gulp.task('production', ['sass:minify'])
gulp.task('default', ['sass', 'webpack', 'browser-sync'], function() {
gulp.watch('./src/scss/**/*', ['sass']);
gulp.watch('./src/js/**/*', ['webpack']);
gulp.watch(['./public/**/*', './public/*']).on('change', reload);
})