forked from heilhead/react-bootstrap-validation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (73 loc) · 2.18 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');
var gutil = require('gulp-util');
var webpack = require('webpack');
var babel = require('gulp-babel');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var dest = "./dist";
var lib = "./lib";
var src = './src';
var entry = src + '/index.js';
var config = {
webpack: {
entry: {
'react-bootstrap': './lib/index.js'
},
output: {
path: './dist',
filename: 'bundle.js',
library: 'ReactBootstrapValidation',
libraryTarget: 'umd'
},
externals: [
{
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
},
{
'react-bootstrap': {
root: 'ReactBootstrap',
commonjs2: 'react-bootstrap',
commonjs: 'react-bootstrap',
amd: 'react-bootstrap'
}
}
],
devtool: 'source-map'
},
babel: {
optional: ['runtime']
}
};
gulp.task('lib', function () {
return gulp.src(['src/**/*.js'])
.pipe(babel(config.babel))
.pipe(gulp.dest(lib));
});
gulp.task('pack', ['lib'], function(callback) {
webpack(config.webpack, function(err, stats) {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack]', stats.toString());
callback();
});
});
gulp.task('minimize', ['pack'], function () {
return gulp.src('dist/bundle.js')
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(gulp.dest(dest))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dest));
});
gulp.task('build', ['minimize']);
gulp.task('default', ['build']);