-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (51 loc) · 1.62 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
var gulp = require('gulp'),
rename = require('gulp-rename'),
browserSync = require('browser-sync').create(),
postcss = require('gulp-postcss'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('autoprefixer'),
precss = require('precss'),
nano = require('gulp-cssnano'),
imagemin = require('gulp-imagemin')
pngcrush = require('imagemin-pngcrush'),
changed = require('gulp-changed');
/**
* Static server; autoprocesses SCSS files, automatically
* updates CSS when it changes, and reloads when HTML does.
*/
gulp.task('serve',['postcss'], function() {
browserSync.init({
server: './'
});
gulp.watch('assets/postcss/**/*.{scss,css}', ['postcss']);
gulp.watch('*.html').on('change', browserSync.reload);
});
/**
* Pngcrushes PNG images in assets/img.
*/
gulp.task('crush', function() {
return gulp.src('./assets/img/src/**/*.{png,gif,jpg}')
.pipe(changed('./assets/img/src/**/*.{png,gif,jpg}'))
.pipe(imagemin({
optimizationLevel: 7,
progressive: true,
use: [pngcrush()]
}))
.pipe(gulp.dest('./assets/img/'));
})
/**
* Makes CSS from pseudo-SASS, adds appropriate vendor
* prefixes, writes maps, spits out to assets/css.
*/
gulp.task('postcss', function () {
return gulp.src('./assets/postcss/*.scss')
.pipe(postcss([
precss(),
autoprefixer({ browsers: ['last 2 versions', 'ie 9', 'ie 10', 'ie 8'] })
]))
.pipe(nano({autoprefixer: false}))
.pipe(rename({extname:'.css'}))
.pipe(gulp.dest('./assets/css/'))
.pipe(browserSync.stream());
});
gulp.task('default',['serve']);