-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (50 loc) · 1.52 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
const gulp = require('gulp');
const cleanCSS = require('gulp-clean-css');
const imagemin = require('gulp-imagemin');
const nodemon = require('gulp-nodemon');
const changed = require('gulp-changed');
const sourcemaps = require('gulp-sourcemaps');
gulp.task('default', ['build']);
// TODO - remove all files in dest before compile
gulp.task('build:prod', ['compile-css:prod', 'compress-images:prod']);
gulp.task('build', ['compile-css', 'compress-images']);
gulp.task('start', () => {
const stream = nodemon({
script: 'start.js',
ext: 'js pug css',
tasks: ['build'],
done: 'done'
});
});
gulp.task('compile-css', () => {
const src = './public/stylesheets/**/*';
const dest = './public/dist/stylesheets';
return gulp.src(src)
.pipe(changed(dest))
.pipe(sourcemaps.init())
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(dest));
});
gulp.task('compress-images', () => {
const src = './public/images/**/*';
const dest = './public/dist/images';
return gulp.src(src)
.pipe(changed(dest))
.pipe(imagemin())
.pipe(gulp.dest(dest));
});
gulp.task('compile-css:prod', () => {
const src = './public/stylesheets/**/*';
const dest = './public/dist/stylesheets';
return gulp.src(src)
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest(dest));
});
gulp.task('compress-images:prod', () => {
const src = './public/images/**/*';
const dest = './public/dist/images';
return gulp.src(src)
.pipe(imagemin())
.pipe(gulp.dest(dest));
});