forked from dingyi1993/jquery-magicsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
42 lines (37 loc) · 1.2 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var cssnano = require('gulp-cssnano');
var gulpif = require('gulp-if');
var autoprefixer = require('gulp-autoprefixer');
var rename = require('gulp-rename');
var clean = require('gulp-clean');
var uglify = require('gulp-uglify');
var sequence = require('gulp-sequence');
var babel = require('gulp-babel');
gulp.task('css', function() {
return gulp.src('src/sass/*.scss')
.pipe(sass())
.pipe(autoprefixer({browsers: ['>1%', 'last 5 versions']}))
.pipe(gulp.dest('dist/css'))
.pipe(cssnano())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/css'));
});
gulp.task('js', function () {
return gulp.src('src/js/*.js')
.pipe(babel())
.pipe(gulp.dest('dist/js'))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('clean', function() {
return gulp.src('dist', {read: false})
.pipe(clean());
});
gulp.task('watch', function() {
gulp.watch('src/sass/*.scss', ['css']);
gulp.watch('src/js/*.js', ['js']);
});
gulp.task('build', sequence('clean', ['css', 'js']));
gulp.task('default', sequence('build', 'watch'));