-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
44 lines (39 loc) · 1.2 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
const path = require('path');
const gulp = require('gulp');
const cleanCSS = require('gulp-clean-css');
const critical = require('critical').stream;
const rename = require('gulp-rename');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const cssPath = ['./css/*.css', '!css/*.min.css'];
const jsPath = ['./js/*.js', '!js/*.min.js'];
gulp.task('css', () => {
return gulp.src(cssPath)
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./css'));
});
gulp.task('critical', () => {
return gulp.src('./index.html')
.pipe(critical({
base: process.cwd(),
inline: false,
css: ['css/main.css', 'css/normalize.css', 'https://code.getmdl.io/1.3.0/material.indigo-pink.min.css'],
minify: true,
}))
.pipe(rename('critical.min.css'))
.pipe(gulp.dest('./css'));
});
gulp.task('js', () => {
return gulp.src(jsPath)
.pipe(babel({
presets: ['env']
}))
.pipe(uglify())
.pipe(rename(({ suffix: '.min' })))
.pipe(gulp.dest('./js'));
});
gulp.task('default', () => {
gulp.watch(cssPath, ['css']);
gulp.watch(jsPath, ['js']);
});