forked from parse-community/ParseReact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (78 loc) · 2.78 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
82
83
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var collapser = require('bundle-collapser/plugin');
var derequire = require('gulp-derequire');
var envify = require('envify/custom');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var insert = require('gulp-insert');
var replace = require('gulp-replace');
var pkg = require('./package.json');
function versionHeader() {
return (
'/*\n' +
' * Parse + React\n' +
' * v' + pkg.version + '\n' +
' */\n'
);
}
function fullHeader() {
return (
'/*\n' +
' * Parse + React\n' +
' * v' + pkg.version + '\n' +
' *\n' +
' * Copyright (c) 2015, Parse, LLC. All rights reserved.\n' +
' *\n' +
' * You are hereby granted a non-exclusive, worldwide, royalty-free license to\n' +
' * use, copy, modify, and distribute this software in source code or binary\n' +
' * form for use in connection with the web services and APIs provided by Parse.\n' +
' *\n' +
' * As with any software that integrates with the Parse platform, your use of\n' +
' * this software is subject to the Parse Terms of Service\n' +
' * [https://www.parse.com/about/terms]. This copyright notice shall be\n' +
' * included in all copies or substantial portions of the software.\n' +
' *\n' +
' * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n' +
' * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n' +
' * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n' +
' * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n' +
' * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n' +
' * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n' +
' * IN THE SOFTWARE.\n' +
' *\n' +
' */\n'
);
}
gulp.task('build', function() {
var stream = browserify({
entries: './src/ParseReact.js',
standalone: 'ParseReact'
})
.transform(envify({NODE_ENV: 'development'}))
.bundle();
return stream.pipe(source('parse-react.js'))
.pipe(derequire())
.pipe(replace('parse_r', 'require'))
.pipe(insert.prepend(versionHeader()))
.pipe(gulp.dest('./dist'));
});
gulp.task('publish', function() {
var stream = browserify({
entries: './src/ParseReact.js',
standalone: 'ParseReact',
builtins: {},
plugins: [collapser],
debug: false
})
.transform(envify({NODE_ENV: 'production'}))
.bundle();
return stream.pipe(source('parse-react.min.js'))
.pipe(derequire())
.pipe(replace('parse_r', 'require'))
.pipe(buffer())
.pipe(uglify())
.pipe(insert.prepend(fullHeader()))
.pipe(gulp.dest('./dist'));
});