forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
217 lines (189 loc) · 6.26 KB
/
Gruntfile.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
'use strict';
var path = require('path');
var GULP_EXE = 'gulp';
if (process.platform === 'win32') {
GULP_EXE += '.cmd';
}
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: require('./grunt/config/browserify'),
npm: require('./grunt/config/npm'),
clean: [
'./build',
'./*.gem',
'./docs/_site',
'./examples/shared/*.js',
'.module-cache',
],
'compare_size': require('./grunt/config/compare_size'),
});
grunt.config.set('compress', require('./grunt/config/compress'));
function spawnGulp(args, opts, done) {
grunt.util.spawn({
// This could be more flexible (require.resolve & lookup bin in package)
// but if it breaks we'll fix it then.
cmd: path.join('node_modules', '.bin', GULP_EXE),
args: args,
opts: Object.assign({stdio: 'inherit'}, opts),
}, function(err, result, code) {
if (err) {
grunt.fail.fatal('Something went wrong running gulp: ', result);
}
done(code === 0);
});
}
Object.keys(grunt.file.readJSON('package.json').devDependencies)
.filter(function(npmTaskName) {
return npmTaskName.indexOf('grunt-') === 0;
})
.filter(function(npmTaskName) {
return npmTaskName !== 'grunt-cli';
})
.forEach(function(npmTaskName) {
grunt.loadNpmTasks(npmTaskName);
});
grunt.registerTask('eslint', function() {
// Use gulp here.
spawnGulp(['eslint'], null, this.async());
});
grunt.registerTask('lint', ['eslint']);
grunt.registerTask('flow', function() {
// Use gulp here.
spawnGulp(['flow'], null, this.async());
});
grunt.registerTask('delete-build-modules', function() {
// Use gulp here.
spawnGulp(['react:clean'], null, this.async());
});
// Our own browserify-based tasks to build a single JS file build.
grunt.registerMultiTask('browserify', require('./grunt/tasks/browserify'));
grunt.registerMultiTask('npm', require('./grunt/tasks/npm'));
var npmReactTasks = require('./grunt/tasks/npm-react');
grunt.registerTask('npm-react:release', npmReactTasks.buildRelease);
grunt.registerTask('npm-react:pack', npmReactTasks.packRelease);
var npmReactDOMTasks = require('./grunt/tasks/npm-react-dom');
grunt.registerTask('npm-react-dom:release', npmReactDOMTasks.buildRelease);
grunt.registerTask('npm-react-dom:pack', npmReactDOMTasks.packRelease);
var npmReactNativeTasks = require('./grunt/tasks/npm-react-native');
grunt.registerTask('npm-react-native:release', npmReactNativeTasks.buildRelease);
grunt.registerTask('npm-react-native:pack', npmReactNativeTasks.packRelease);
var npmReactAddonsTasks = require('./grunt/tasks/npm-react-addons');
grunt.registerTask('npm-react-addons:release', npmReactAddonsTasks.buildReleases);
grunt.registerTask('npm-react-addons:pack', npmReactAddonsTasks.packReleases);
var npmReactTestRendererTasks = require('./grunt/tasks/npm-react-test');
grunt.registerTask('npm-react-test:release', npmReactTestRendererTasks.buildRelease);
grunt.registerTask('npm-react-test:pack', npmReactTestRendererTasks.packRelease);
grunt.registerTask('version-check', function() {
// Use gulp here.
spawnGulp(['version-check'], null, this.async());
});
grunt.registerTask('build:basic', [
'build-modules',
'version-check',
'browserify:basic',
]);
grunt.registerTask('build:addons', [
'build-modules',
'browserify:addons',
]);
grunt.registerTask('build:min', [
'build-modules',
'version-check',
'browserify:min',
]);
grunt.registerTask('build:addons-min', [
'build-modules',
'browserify:addonsMin',
]);
grunt.registerTask('build:dom', [
'build-modules',
'version-check',
'browserify:dom',
]);
grunt.registerTask('build:dom-min', [
'build-modules',
'version-check',
'browserify:domMin',
]);
grunt.registerTask('build:dom-server', [
'build-modules',
'version-check',
'browserify:domServer',
]);
grunt.registerTask('build:dom-server-min', [
'build-modules',
'version-check',
'browserify:domServerMin',
]);
grunt.registerTask('build:dom-fiber', [
'build-modules',
'version-check',
'browserify:domFiber',
]);
grunt.registerTask('build:dom-fiber-min', [
'build-modules',
'version-check',
'browserify:domFiberMin',
]);
grunt.registerTask('build:npm-react', [
'version-check',
'build-modules',
'npm-react:release',
]);
var jestTasks = require('./grunt/tasks/jest');
grunt.registerTask('jest:normal', jestTasks.normal);
grunt.registerTask('jest:coverage', jestTasks.coverage);
grunt.registerTask('test', ['jest:normal']);
grunt.registerTask('npm:test', ['build', 'npm:pack']);
// Optimized build task that does all of our builds. The subtasks will be run
// in order so we can take advantage of that and only run build-modules once.
grunt.registerTask('build', [
'delete-build-modules',
'build-modules',
'version-check',
'browserify:basic',
'browserify:addons',
'browserify:min',
'browserify:addonsMin',
'browserify:dom',
'browserify:domMin',
'browserify:domServer',
'browserify:domServerMin',
'browserify:domFiber',
'browserify:domFiberMin',
'npm-react:release',
'npm-react:pack',
'npm-react-dom:release',
'npm-react-dom:pack',
'npm-react-native:release',
'npm-react-native:pack',
'npm-react-addons:release',
'npm-react-addons:pack',
'npm-react-test:release',
'npm-react-test:pack',
'compare_size',
]);
// Automate the release!
var releaseTasks = require('./grunt/tasks/release');
grunt.registerTask('release:setup', releaseTasks.setup);
grunt.registerTask('release:bower', releaseTasks.bower);
grunt.registerTask('release:docs', releaseTasks.docs);
grunt.registerTask('release:msg', releaseTasks.msg);
grunt.registerTask('release:starter', releaseTasks.starter);
grunt.registerTask('release', [
'release:setup',
'clean',
'build',
'release:bower',
'release:starter',
'compress',
'release:docs',
'release:msg',
]);
grunt.registerTask('build-modules', function() {
spawnGulp(['react:modules'], null, this.async());
});
// The default task - build - to keep setup easy.
grunt.registerTask('default', ['build']);
};