-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
73 lines (63 loc) · 1.73 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
'use strict';
const gulp = require('gulp');
const browserSync = require('browser-sync');
const postcss = require('gulp-postcss');
const processInline = require('gulp-process-inline');
const inlineSource = require('gulp-inline-source');
const htmlmin = require('gulp-htmlmin');
const eslint = require('gulp-eslint');
const autoprefixer = require('autoprefixer');
const minify = require('gulp-htmlmin');
const argv = require('yargs').argv;
const gulpif = require('gulp-if');
const prettify = require('gulp-html-prettify');
gulp.task('build', () => {
const styles = processInline();
const scripts = processInline();
const noMinify = argv.minify === false;
return gulp.src(['src/*.html'])
.pipe(inlineSource({
compress: false,
swallowErrors: true
}))
// JS
.pipe(scripts.extract('script'))
.pipe(eslint())
.pipe(eslint.format())
.pipe(scripts.restore())
// HTML
.pipe(gulpif(!noMinify, minify({
removeComments: true,
removeCommentsFromCDATA: true,
collapseWhitespace: true,
conservativeCollapse: true,
caseSensitive: true,
keepClosingSlash: true,
customAttrAssign: [/\$=/],
minifyCSS: true,
minifyJS: true
})))
.pipe(gulpif(noMinify, prettify({
indent_char: ' ',
indent_size: 2
})))
.pipe(gulp.dest('.'));
});
gulp.task('browserSync', () => {
browserSync({
server: {
baseDir: './',
index: 'index.html',
routes: {
'/': './bower_components'
}
},
open: false,
notify: false,
ghostMode: false
});
});
gulp.task('watch', () => {
gulp.watch(['src/**/*', 'demo/**/*', 'test/**/*'], ['build', browserSync.reload]);
});
gulp.task('default', ['build', 'browserSync', 'watch']);