forked from AuHau/select-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
90 lines (74 loc) · 2.87 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
82
83
84
85
86
87
88
89
90
'use strict';
var gulp = require('gulp');
var gulpLoadPlugins = require('gulp-load-plugins');
var plugins = gulpLoadPlugins();
var mainBowerFiles = require('main-bower-files');
var merge = require('merge-stream');
var LessPluginCleanCSS = require("less-plugin-clean-css"),
cleancss = new LessPluginCleanCSS({advanced: true});
var LessPluginAutoPrefix = require('less-plugin-autoprefix'),
autoprefix = new LessPluginAutoPrefix({browsers: ["last 2 versions"]});
gulp.task('css:big', function () {
return gulp.src('src/picker.less')
.pipe(plugins.less({
plugins: [autoprefix]
}))
.on('error', plugins.notify.onError("Error: <%= error.file %> <%= error.message %>"))
.pipe(plugins.rename('picker.css'))
.pipe(gulp.dest('dist/'))
.pipe(plugins.notify('CSS build finished'));
});
gulp.task('css:min', function () {
return gulp.src('src/picker.less')
.pipe(plugins.less({
plugins: [autoprefix, cleancss]
}))
.on('error', plugins.notify.onError("Error: <%= error.file %> <%= error.message %>"))
.pipe(plugins.rename('picker.min.css'))
.pipe(gulp.dest('dist/'))
.pipe(plugins.notify('CSS:min build finished'));
});
gulp.task('js:min', function () {
return gulp.src('src/picker.js')
.pipe(plugins.uglify())
.pipe(plugins.rename('picker.min.js'))
.pipe(gulp.dest('dist/'));
});
gulp.task('doc:js', function () {
var libs = gulp.src(mainBowerFiles('**/*.js', {'includeDev': true}))
.pipe(plugins.concat('libs.js'))
.pipe(plugins.uglify())
.on('error', function (err) {
console.log(err)
})
.pipe(gulp.dest('docs/js/'));
var src = gulp.src('src/picker.js')
.pipe(gulp.dest('docs/js/'));
return merge(libs, src)
.on('error', plugins.notify.onError("Error: <%= error.file %> <%= error.message %>"))
.pipe(plugins.notify('JS done!'));
});
gulp.task('doc:css', function () {
var files = mainBowerFiles('**/*.css', {'includeDev': true});
files.push('dist/picker.css');
return gulp.src('docs/css/main.less')
.pipe(plugins.less({
plugins: [autoprefix, cleancss]
}))
.pipe(plugins.addSrc.prepend(files))
.pipe(plugins.minifyCss())
.on('error', plugins.notify.onError("Error: <%= error.file %> <%= error.message %>"))
.pipe(plugins.concat('main.css'))
.pipe(gulp.dest('docs/css/'))
.pipe(plugins.notify('Doc:css build finished'));
});
gulp.task('css', ['css:big', 'css:min']);
gulp.task('doc', ['doc:css', 'doc:js']);
gulp.task('build', ['doc', 'css', 'js:min']);
gulp.task('doc:watch', ['doc'], function () {
gulp.watch('docs/css/main.less', ['doc:css']);
gulp.watch('src/picker.js', ['doc:js']);
});
gulp.task('default', ['build'], function () {
gulp.watch('src/picker.less', ['css:big']);
});