-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
45 lines (40 loc) · 1.33 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
var gulp = require('gulp');
var sass = require("gulp-ruby-sass");
var cleanCSS = require('gulp-clean-css');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var sourcemaps = require('gulp-sourcemaps');
gulp.task('serve',['minify-css'],function(){
browserSync.init({
server: "./"
});
gulp.watch("./src/scss/**/*.scss", ['minify-css']);
gulp.watch("./*.html").on('change', reload);
gulp.watch("./dist/js/*.js").on('change',reload);
});
gulp.task('sass',function(){
return sass('./src/scss/pages/*.scss', {sourcemap: true})
.on('error', function (err) {
console.error('Error!', err.message);
})
.pipe(sourcemaps.write('./', {
includeContent: false,
sourceRoot: '../../src/scss/pages/'
}))
.pipe(gulp.dest('./src/css/'));
});
gulp.task('autoprefixer',['sass'],function(){
return gulp.src('./src/css/*.css')
.pipe(sourcemaps.init())
.pipe(autoprefixer())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./src/css/'));
});
gulp.task('minify-css',['autoprefixer'], function(){
return gulp.src('./src/css/*.css')
.pipe(cleanCSS())
.pipe(gulp.dest('./dist/css/'))
.pipe(browserSync.stream());
});
gulp.task('default', ['serve']);