-
Notifications
You must be signed in to change notification settings - Fork 21
/
gulpfile.js
81 lines (68 loc) · 1.74 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
74
75
76
77
78
79
80
81
var gulp = require('gulp'),
$ = require('gulp-load-plugins')();
//watch
gulp.task('watch', ['default'], function() {
gulp.watch('lib/**/*', ['default']);
});
//default
gulp.task('default', ['styles', 'js', 'html']);
//////////////////
/*
Styles
*/
const baseConfig = {
baseDir: 'static/',
maxSize: 14 * 1024,
debug: false
};
//merged css
gulp.task('styles', ['styles_single'], function() {
return gulp.src(['lib/styles/main/*.less', 'lib/styles/main/*.css'])
.pipe($.sourcemaps.init())
.pipe($.concat('main.css'))
.pipe($.less())
.pipe($.inlineBase64(baseConfig))
.pipe($.autoprefixer({
browsers: ['> 5%']
}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist/styles'));
});
//single css files
gulp.task('styles_single', function() {
return gulp.src(['lib/styles/*.less', 'lib/styles/*.css'])
.pipe($.sourcemaps.init())
.pipe($.less())
.pipe($.inlineBase64(baseConfig))
.pipe($.autoprefixer({
browsers: ['> 5%']
}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist/styles'));
});
/*
js
*/
gulp.task('js', function() {
return gulp.src('lib/js/*.js')
.pipe($.sourcemaps.init())
.pipe($.babel({
presets: ['es2015']
}))
//.pipe($.concat('main.js'))
.pipe($.uglify())
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist/js'));
});
/*
html
*/
gulp.task('html', ['styles', 'js'], function() {
return gulp.src('lib/index.html')
.pipe($.inlineSource({rootpath:'.'}))
.pipe($.htmlmin({
collapseWhitespace: true,
sortAttributes: true
}))
.pipe(gulp.dest('.'));
});