-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathgulpfile.js
64 lines (53 loc) · 1.4 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
insert = require('gulp-insert'),
webpack = require('gulp-webpack')
;
var packageName = 'react-json';
var pack = require( './package.json' );
var getWPConfig = function( filename ){
return {
externals: {
react: {
root: 'React'
}
},
output: {
libraryTarget: 'umd',
library: 'Json',
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('./Json.js')
.pipe( webpack( config ) )
;
if( minify ){
stream.pipe( uglify() );
}
return stream.pipe( insert.prepend( cr ) )
.pipe( gulp.dest('build/') )
;
}
gulp.task("build", function( callback ) {
var config = getWPConfig( 'Json' );
config.devtool = '#eval';
wp( config );
config = getWPConfig( 'Json.min' );
wp( config, true );
config = getWPConfig( 'Json-no-freezer' );
config.devtool = '#eval';
config.externals['freezer-js'] = { root: 'Freezer' };
wp( config );
config = getWPConfig( 'Json-no-freezer.min' );
config.externals['freezer-js'] = { root: 'Freezer' };
return wp( config, true );
});
gulp.task( 'default', ['build'] );