forked from lvn/elvinyung.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
72 lines (63 loc) · 1.88 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
'use strict';
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
del = require('del'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
livereload = require('gulp-livereload'),
jshint = require('gulp-jshint'),
notify = require('gulp-notify'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
htmlreplace = require('gulp-html-replace');;
var paths = {
js: ['site/js/*.js', '!site/js/vendor/**/*.js'],
scss: 'site/scss/style.scss',
index: 'site/index.html'
};
var dests = {
js: 'dist/js',
css: 'dist/css',
index: 'dist'
};
gulp.task('clean', function(cb) {
del('dist', cb);
});
gulp.task('js', function () {
return gulp.src(paths.js)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('site.js'))
.pipe(rename({ suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(dests.js))
.pipe(notify({ mesage: 'linted and minified js' }));
});
gulp.task('scss', function() {
return gulp.src(paths.scss)
.pipe(sass({ errLogToConsole: true }))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(rename({suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest(dests.css))
.pipe(notify({ message: 'compiled and minified scss' }));
});
gulp.task('index', function() {
return gulp.src(paths.index)
.pipe(htmlreplace({
'css': 'css/style.min.css',
'js': 'js/site.min.js'
}))
.pipe(gulp.dest(dests.index))
.pipe(notify({ message: 'copied index.html to dist/index.html' }))
});
gulp.task('watch', function() {
gulp.watch(paths.js, ['js']);
gulp.watch(paths.scss, ['scss']);
livereload.listen();
ulp.watch(['dist/**']).on('change', livereload.changed);
});
gulp.task('default', ['clean'], function() {
gulp.start('js', 'scss', 'index');
});