forked from arqex/react-datetime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (49 loc) · 1.2 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
insert = require('gulp-insert'),
webpack = require('gulp-webpack')
;
var packageName = 'react-datetime';
var pack = require( './package.json' );
var getWPConfig = function( filename ){
return {
externals: {
react: {
root: 'React',
},
moment: {
root: 'moment'
}
},
output: {
libraryTarget: 'umd',
library: 'Datetime',
filename: filename + '.js'
}
};
};
var cr = ('/*\n%%name%% v%%version%%\n%%homepage%%\n%%license%%: https://github.com/arqex/' + packageName + '/raw/master/LICENSE\n*/\n')
.replace( '%%name%%', pack.name)
.replace( '%%version%%', pack.version)
.replace( '%%license%%', pack.license)
.replace( '%%homepage%%', pack.homepage)
;
function wp( config, minify ){
var stream = gulp.src('./Datetime.js')
.pipe( webpack( config ) )
;
if( minify ){
stream.pipe( uglify() );
}
return stream.pipe( insert.prepend( cr ) )
.pipe( gulp.dest('dist/') )
;
}
gulp.task("build", function( callback ) {
var config = getWPConfig( 'react-datetime' );
config.devtool = '#eval';
wp( config );
config = getWPConfig( 'react-datetime.min' );
return wp( config, true );
});
gulp.task( 'default', ['build'] );