-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
65 lines (58 loc) · 1.39 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
const cssnano = require('gulp-cssnano');
const cssnext = require('postcss-cssnext');
const gulp = require('gulp');
const postcss = require('gulp-postcss');
const postcssImport = require('postcss-import');
const rev = require('gulp-rev-all');
const sourcemaps = require('gulp-sourcemaps');
const uncss = require('gulp-uncss');
const processors = [
postcssImport,
cssnext({
browsers: ['last 1 version'],
}),
];
gulp.task('css', () => {
return gulp
.src('assets/css/app.css')
.pipe(sourcemaps.init())
.pipe(postcss(processors))
.pipe(sourcemaps.write())
.pipe(gulp.dest('public'));
});
gulp.task('css:watch', ['css'], () => {
gulp.watch('assets/css/**/*', ['css']);
});
gulp.task('css:build', () => {
return gulp
.src('assets/css/app.css')
.pipe(postcss(processors))
.pipe(
uncss({
html: ['public/**/*.html'],
}),
)
.pipe(
cssnano({
discardComments: {
removeAll: true,
},
}),
)
.pipe(gulp.dest('public'));
});
gulp.task('rev', () => {
return gulp
.src('public/**/*')
.pipe(
rev.revision({
dontRenameFile: ['.html', '.json', '.xml'],
dontUpdateReference: ['.html', '.json', '.xml'],
}),
)
.pipe(gulp.dest('public'))
.pipe(rev.manifestFile())
.pipe(gulp.dest('public'));
});
gulp.task('build', ['css:build']);
gulp.task('watch', ['css:watch']);