-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
46 lines (38 loc) · 1.18 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var concat = require('gulp-concat');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var merge = require('merge-stream');
var cssnano = require('gulp-cssnano');
var sass = require('gulp-sass');
sass.compiler = require('node-sass');
// Static server
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "."
}
});
});
// sass
gulp.task('sass', function() {
return gulp.src('sass/main.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer(['last 2 versions'], { cascade: true }))
.pipe(gulp.dest('css/'))
.pipe(browserSync.reload({stream: true}))
});
//min
gulp.task('css-min', function() {
return gulp.src('css/all.css')
.pipe(cssnano())
.pipe(gulp.dest('css/'))
});
// gulp watch
gulp.task('watch', ['browser-sync', 'sass'], function() {
gulp.watch('*.html', browserSync.reload);
gulp.watch('js/**/*.js', browserSync.reload);
gulp.watch('sass/**/*.scss', ['sass'], browserSync.reload);
});
gulp.task('default', ['watch']);