-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathgulpfile.js
51 lines (43 loc) · 1.1 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
insert = require('gulp-insert'),
webpack = require('gulp-webpack')
;
var packageName = 'react-json-table';
var pack = require( './package.json' );
var getWPConfig = function( filename ){
return {
externals: {
react: {
root: 'React'
}
},
output: {
libraryTarget: 'umd',
library: 'JsonTable',
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 build( config, minify ){
var stream = gulp.src('./rjt.js')
.pipe( webpack( config ) )
;
if( minify ){
stream.pipe( uglify() );
}
return stream.pipe( insert.prepend( cr ) )
.pipe( gulp.dest('build/') )
;
}
gulp.task("build", function( callback ) {
build( getWPConfig( packageName ) );
return build( getWPConfig( packageName + '.min' ), true );
});
gulp.task( 'default', ['build'] );