forked from wing-kai/react-bootstrap-datetime-range-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
66 lines (57 loc) · 1.91 KB
/
gulpfile.js
File metadata and controls
66 lines (57 loc) · 1.91 KB
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
"use strict";
const gulp = require('gulp');
const babel = require('gulp-babel');
const plumber = require('gulp-plumber');
const notify = require('gulp-notify');
const minifyCss = require('gulp-minify-css'); // css压缩
const rename = require('gulp-rename');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const onError = err => {
notify.onError({
title: "Error",
message: err.message.replace(/.+\/(.+\.(jsx|js).+)/g, '$1'),
// message: err.message,
sound: "Beep"
})(err);
};
gulp.task('bundle', ['script'], () => {
const bundle = browserify({
entries: './lib/picker',
standalone: 'DateTimeRangePicker',
shim: {
"react": {
"exports": "global:React"
},
"react-dom": {
"exports": "global:ReactDOM"
}
}
});
return bundle.bundle().pipe(source("react-bootstrap-datetime-range-picker.js")).pipe(buffer()).pipe(gulp.dest("./dist"));
});
gulp.task('script', () => (
gulp.src(['./src/**/*.js', './src/**/*.jsx']).pipe(plumber({
errorHandler: onError
})).pipe(babel({
compact: false,
presets: ["react", 'es2015'],
plugins: [
// "transform-es2015-modules-commonjs",
"transform-object-rest-spread"
]
})).pipe(plumber({
errorHandler: onError
})).pipe(rename({
extname: '.js'
})).pipe(gulp.dest('lib'))
));
gulp.task('stylesheet', () => (
gulp.src('./src/**/*.css').pipe(minifyCss()).pipe(gulp.dest('./dist'))
));
gulp.task('watch', () => {
gulp.watch(['./src/**/*.js', './src/**/*.jsx', './src/**/*.css'], ['stylesheet', 'script', 'bundle']);
});
gulp.task('deploy', ['stylesheet', 'script', 'bundle']);
gulp.task('default', ['stylesheet', 'script', 'bundle', 'watch']);