-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
79 lines (66 loc) · 1.83 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
71
72
73
74
75
76
77
78
79
var gulp = require('gulp');
var postcss = require('gulp-postcss');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var cleanCSS = require('gulp-clean-css');
var browserSync = require('browser-sync');
var autoprefixer = require('autoprefixer');
// 编译Sass
gulp.task('css', function() {
var processors = [autoprefixer({
browsers: [
"Android 2.3",
"Android >= 4",
"Chrome >= 20",
"Firefox >= 24",
"Explorer >= 8",
"iOS >= 6",
"Opera >= 12",
"Safari >= 6"
]
})];
gulp.src('./scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('./dist'))
.pipe(postcss(processors))
.pipe(cleanCSS())
.pipe(gulp.dest('./css'));;
});
gulp.task('js', function() {
gulp.src([
'./js/vendor/jquery-3.1.1.min.js',
'./js/vendor/holder-2.9.min.js',
'./js/vendor/masonry.4.1.1.min.js',
'./venders/bootstrap-sass-3.3.7/assets/javascripts/bootstrap.min.js',
'./js/plugin.js',
'./js/main.js'
])
.pipe(concat('all.js'))
.pipe(gulp.dest('./js'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./js'));
});
gulp.task('browser-sync', function() {
var files = [
'./**/*.html',
'css/main.css',
'img/**/*.png',
'js/all.min.js'
];
browserSync.init(files, {
server: {
baseDir: './'
}
});
});
// 默认任务
gulp.task('default', function() {
gulp.run('css', 'js', 'browser-sync');
// 监听文件变化
gulp.watch(['./js/main.js', './js/plugins.js', './scss/**/*.scss'], function() {
gulp.run('css', 'js');
});
});