-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
93 lines (82 loc) · 2.27 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var notify = require('gulp-notify');
var minifycss = require('gulp-cssnano');
var concat = require('gulp-concat');
var plumber = require('gulp-plumber');
var neat = require('node-neat');
var browserSync = require('browser-sync');
var autoprefixer = require('gulp-autoprefixer');
var reload = browserSync.reload;
var useref = require('gulp-useref');
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var cssnano = require('gulp-cssnano');
var del = require('del');
var runSequence = require('run-sequence');
gulp.task('js', function() {
return gulp.src(['./app/js/*.js'], ['!./app/js/concat.js'])
.pipe(concat('concat.js'))
.pipe(gulp.dest('./app/js'))
});
gulp.task('sass', function () {
gulp.src('./app/scss/*.scss')
.pipe(plumber())
.pipe(sass({
includePaths: ['scss'].concat(neat)
}))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('./app/scss/tmp'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('./app/css'))
});
gulp.task('reload', function () {
browserSync.reload();
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./app"
}
});
});
gulp.task('useref', function(){
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulpIf('*.js', uglify()))
// Minifies only if it's a CSS file
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('docs'))
});
gulp.task('clean:dist', function() {
return del.sync('dist');
});
gulp.task('clean:docs', function() {
return del.sync('docs');
});
gulp.task('modernizr-2', function() {
return gulp.src('app/js/modernizr-2.6.2.min.js')
.pipe(gulp.dest('docs/js'))
});
gulp.task('copy-icons', function() {
return gulp.src('app/*.png')
.pipe(gulp.dest('docs'))
});
gulp.task('build', function (callback) {
runSequence('clean:docs',
['sass', 'useref', 'modernizr-2', 'copy-icons'],
callback
)
});
gulp.task('default', ['js', 'sass', 'browser-sync'], function () {
gulp.watch(['./app/css/*.css'], ['reload'])
gulp.watch(['./app/scss/*.scss', 'scss/**/*.scss'], ['sass'])
gulp.watch(['./app/js/*'], ['js'], ['reload'])
gulp.watch(['./app/*.html'], ['reload']);
});