-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
56 lines (49 loc) · 1.27 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
'use strict';
var gulp = require('gulp'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
connect = require('gulp-connect'),
csscomb = require('gulp-csscomb'),
sass = require('gulp-sass'),
flexbugs = require('postcss-flexbugs-fixes'),
babel = require('gulp-babel');
//connect
gulp.task('connect', function() {
connect.server({
root: './app/',
livereload: true,
port: 8888
});
});
//js
gulp.task('js', function() {
return gulp.src('./js/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('./app/js/'))
.pipe(connect.reload());
});
//css
gulp.task('css', function() {
var processors = [autoprefixer({browsers: ['last 3 version', 'ie 9', 'ie 10', 'ie 11']}), flexbugs];
return gulp.src('./scss/main.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss(processors))
.pipe(csscomb())
.pipe(gulp.dest('./app/css/'))
.pipe(connect.reload());
});
//html
gulp.task('html', function(){
return gulp.src('./app/index.html')
.pipe(connect.reload());
});
//watch
gulp.task('watch', function(){
gulp.watch('./js/*.js', ['js']);
gulp.watch('./scss/*.scss', ['css']);
gulp.watch('./app/index.html', ['html']);
});
//default
gulp.task('default', ['connect', 'js', 'html', 'css', 'watch']);