-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
46 lines (38 loc) · 1.07 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
var gulp = require('gulp');
var replace = require('gulp-replace');
var minify = require('gulp-minifier');
var clean = require('gulp-clean');
var fs = require('fs');
var minifier = function() {
return minify({
minify: true,
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true,
});
};
gulp.task('clean', function() {
return gulp.src('./dist/', {read: false})
.pipe(clean());
});
gulp.task('css', ['clean'], function() {
return gulp.src('./src/css/style.css')
.pipe(minifier())
.pipe(gulp.dest('./dist/css/'));
});
gulp.task('js', ['clean', 'css'], function() {
return gulp.src('./src/js/index.js')
.pipe(replace('GULP_REPLACE_STYLES', function(s) {
return fs.readFileSync('./dist/css/style.css', 'utf8');
}))
.pipe(minifier())
.pipe(gulp.dest('./dist/'));
});
gulp.task('images', ['clean'], function() {
return gulp.src('./src/images/**/*')
.pipe(gulp.dest('./dist/images/'));
});
gulp.task('build', ['css', 'js', 'images']);
gulp.task('default', ['build'], function() {
gulp.watch(['./src/**/*'], ['build']);
});