-
Notifications
You must be signed in to change notification settings - Fork 15
/
gulpfile.js
127 lines (106 loc) · 3.08 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
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
var path = require('path');
var util = require('util');
var gulp = require('gulp-help')(require('gulp'));
var gulpBabel = require('gulp-babel');
var gulpRename = require('gulp-rename');
var gulpShell = require('gulp-shell');
var gulpUtil = require('gulp-util');
var mergeStream = require('merge-stream');
var merge = require('lodash/object/merge');
var minimist = require('minimist');
gulp.task('clean', 'Clean built files.', function (cb) {
var del = require('del');
del('dist', cb);
});
gulp.task('build', 'Build for all targets.', [
'build-amd',
'build-cjs',
'build-examples'
]);
gulp.task('build-amd', 'Build for AMD.', function () {
var gulpWrapAMD = require('gulp-wrap-amd');
var copy = gulp
.src('tools/copy/amd/**')
.pipe(gulp.dest('dist/amd'));
var src = gulp
.src('src/**/*.{js,jsx}')
.pipe(gulpBabel())
.pipe(gulpWrapAMD())
.pipe(gulpRename({extname: '.js'}))
.pipe(gulp.dest('dist/amd'));
return mergeStream(copy, src);
});
gulp.task('build-cjs', 'Build for CommonJS.', function () {
var copy = gulp
.src('tools/publish/cjs/**')
.pipe(gulp.dest('dist/cjs'));
var src = gulp
.src('src/**/*.{js,jsx}')
.pipe(gulpBabel())
.pipe(gulpRename({extname: '.js'}))
.pipe(gulp.dest('dist/cjs'));
return mergeStream(copy, src);
});
gulp.task('build-examples', 'Build examples.', function () {
var build = gulp.src('')
.pipe(gulpShell([
'node_modules/.bin/webpack',
'--colors',
'--config examples/webpack.config.prod.js',
'--profile',
'--progress'
].join(' '), {cwd: __dirname}));
var copy = gulp
.src('tools/publish/examples/**')
.pipe(gulp.dest('dist/examples'));
return mergeStream(build, copy);
});
gulp.task('examples', 'Run examples.', function () {
var options = minimist(process.argv.slice(2), {
alias: {
p: 'port'
},
default: {
port: 8080
}
});
gulpUtil.log('[webpack-dev-server]', util.format('http://localhost:%d/', options.port));
return gulp.src('')
.pipe(gulpShell([
'node_modules/.bin/webpack-dev-server',
'--colors',
'--config examples/webpack.config.js',
'--content-base examples',
'--hot',
'--inline',
util.format('--port %d', options.port),
'--progress'
].join(' '), {cwd: __dirname}));
}, {
options: {
'port <port>': 'port (default: 8080)'
}
});
gulp.task('publish', 'Publish all targets.', [
'publish-amd',
'publish-cjs'
]);
gulp.task('publish-amd', 'Publish AMD.', function () {
});
gulp.task('publish-cjs', 'Publish CommonJS.', function () {
return gulp.src('')
.pipe(gulpShell([
'npm publish dist/cjs'
], {cwd: __dirname}));
});
gulp.task('publish-examples', 'Publish Examples.', function () {
return gulp.src('')
.pipe(gulpShell([
'git init',
'git add .',
'git commit -m Publish',
'git remote add origin git@github.com:react-famous/react-famous.github.io.git',
'git push -fu origin master'
].join('&&'), {cwd: path.join(__dirname, 'dist/examples')}));
});
gulp.task('default', false, ['help']);