-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (62 loc) · 1.82 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
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var cssbeautify = require('gulp-cssbeautify');
var cleanCSS = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps')
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
// Browser Sync - live preview
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
});
gulp.task('watch', ['browserSync'], function() {
gulp.watch('*.html', browserSync.reload);
gulp.watch('css/style.css', browserSync.reload);
gulp.watch('js/*.js', browserSync.reload);
});
// CSS Beautify - format css styles to be easy to read
gulp.task('beautify', function(){
gulp.src('css/style.css')
.pipe(cssbeautify())
.pipe(gulp.dest('dest/css'))
});
// Autoprefixer - prefixes for browsers support
gulp.task('autoprefixer', function() {
gulp.src('css/style.css')
.pipe(autoprefixer({
browsers: ['Safari >= 6.1', 'IE >= 10', 'Firefox >= 28'],
cascade: false}))
.pipe(gulp.dest('dest/css'))
});
// Mix beautify and autoprefixer
gulp.task('mix-css', function(){
gulp.src('css/style.css')
.pipe(cssbeautify())
.pipe(autoprefixer({
browsers: ['Safari >= 6.1', 'IE >= 10', 'Firefox >= 28'],
cascade: false}))
.pipe(gulp.dest('dest/css'))
});
// Minify css & create source map
gulp.task('min-css', function() {
return gulp.src('css/style.css')
.pipe(sourcemaps.init())
.pipe(concat('style.min.css'))
.pipe(cleanCSS())
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('maps'))
});
// Minify JS
gulp.task('uglify', function() {
gulp.src('js/main.js')
.pipe(sourcemaps.init())
.pipe(concat('main.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('maps'));
});