-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
82 lines (73 loc) · 2.11 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
var gulp = require('gulp'),
livereload = require('gulp-livereload'),
processhtml = require('gulp-processhtml'),
htmlmin = require('gulp-htmlmin'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
minify = require('gulp-minify-css'),
prefix = require('gulp-autoprefixer'),
template = require('gulp-md-template');
plumber = require('gulp-plumber');
gulp.task('css', function () {
return gulp.src('./src/css/main.scss')
.pipe(sass())
.pipe(prefix())
.pipe(minify())
.pipe(rename('main.min.css'))
.pipe(gulp.dest('./build/css/'));
});
gulp.task('css-dev', function () {
return gulp.src('./src/css/main.scss')
.pipe(sourcemaps.init())
.pipe(plumber())
.pipe(sass())
.pipe(prefix())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./src/css/'));
});
gulp.task('js', function () {
return gulp.src([
'google.js',
'utils.js',
'github.js',
'twitter.js',
'home.js'
], {cwd: './src/js/'})
.pipe(concat('main.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./build/js/'));
});
gulp.task('html', function () {
return gulp.src('./src/**/*.html')
.pipe(template('./src/articles/'))
.pipe(processhtml())
.pipe(htmlmin({
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true
}))
.pipe(gulp.dest('./build/'));
});
gulp.task('copy', function () {
gulp.src('./src/fonts/*')
.pipe(gulp.dest('./build/fonts/'));
gulp.src('./src/images/*')
.pipe(gulp.dest('./build/images/'));
});
gulp.task('reload', function () {
setTimeout(function () { livereload.changed('/'); }, 1000);
});
gulp.task('watch', function () {
livereload.listen();
gulp.watch('./src/css/*.scss', ['css-dev']);
gulp.watch('./src/**/*', ['reload']);
});
gulp.task('default', ['css', 'js', 'html', 'copy']);