-
Notifications
You must be signed in to change notification settings - Fork 18
/
gulpfile.js
79 lines (68 loc) · 2.55 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
/*vim: fileencoding=utf8 tw=100 expandtab ts=4 sw=4 */
/*jslint indent: 4, maxlen: 100, node: true */
(function () {
'use strict';
let concat = require('gulp-concat'),
babel = require('gulp-babel'),
gulp = require('gulp'),
plumber = require('gulp-plumber'),
uglify = require('gulp-uglify'),
less = require('gulp-less'),
glob = require('glob'),
LessPluginCleanCSS = require('less-plugin-clean-css'),
LessPluginAutoPrefix = require('less-plugin-autoprefix'),
cleancss = new LessPluginCleanCSS({advanced: true}),
autoprefix = new LessPluginAutoPrefix({browsers: ['last 3 versions']});
gulp.task('build:app', function () {
gulp.src('dev/shareSelectedText.js')
.pipe(plumber())
.pipe(babel())
.pipe(concat('shareSelectedText.js'))
.pipe(gulp.dest('dist'));
return gulp.src('dev/shareSelectedText.js')
.pipe(plumber())
.pipe(babel())
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(concat('shareSelectedText.min.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('build:less:demo', function () {
return gulp.src('demo/demo.less')
.pipe(plumber({
handleError: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(less({
plugins: [autoprefix, cleancss]
}))
.pipe(concat('demo.min.css'))
.pipe(gulp.dest('demo'));
});
gulp.task('build:less:app', function () {
return gulp.src(['dev/sst_icons.css', 'dev/shareSelectedText.less'])
.pipe(plumber({
handleError: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(less({
plugins: [autoprefix, cleancss]
}))
.pipe(concat('shareSelectedText.min.css'))
.pipe(gulp.dest('dist'));
});
gulp.task('build:copy:fonts', function () {
return gulp.src(['dev/fonts/**/*']).pipe(gulp.dest('dist/fonts'));
});
gulp.task('build:all', ['build:app', 'build:less:app', 'build:less:demo', 'build:copy:fonts']);
gulp.task('watch', function () {
gulp.watch('dev/shareSelectedText.js', ['build:app']);
gulp.watch('**/*.less', ['build:less:app', 'build:less:demo']);
});
gulp.task('default', ['build:all', 'watch']);
}());