-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
83 lines (73 loc) · 1.92 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
const gulp = require('gulp');
const path = require('path');
const gutil = require('gulp-util');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const webpackConfig = require('./webpack.config.js');
const Karma = require('karma');
const merge = require('webpack-merge');
const babel = require('gulp-babel');
const env = require('gulp-env');
const del = require('del');
gulp.task('examples', () => {
const config = merge(webpackConfig, {
devtool: 'cheap-module-eval-source-map',
output: {
path: '/__build__',
publicPath: '/__build__/',
},
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'react-hot-loader/patch',
'./examples/index.jsx',
],
});
new WebpackDevServer(webpack(config), {
publicPath: '/__build__/',
contentBase: './examples',
hot: true,
historyApiFallback: true,
stats: {
colors: true,
},
}).listen(3000, () => {
gutil.log('Examples served at localhost:3000');
});
});
gulp.task('test', (done) => {
new Karma.Server({
configFile: path.join(__dirname, 'karma.conf.js'),
autoWatch: false,
singleRun: true,
}, () => {
done();
}).start();
});
gulp.task('tdd', (done) => {
new Karma.Server({
configFile: path.join(__dirname, 'karma.conf.js'),
reporters: ['mocha'],
}, done).start();
});
gulp.task('build:es', ['clean:es'], () => {
env({
BABEL_ENV: 'es',
});
return gulp.src('src/**/*')
.pipe(babel())
.pipe(gulp.dest('es'));
});
gulp.task('build:cjs', ['clean:cjs'], () => {
env({
BABEL_ENV: 'commonjs',
});
return gulp.src('src/**/*')
.pipe(babel())
.pipe(gulp.dest('lib'));
});
gulp.task('clean:cjs', () => del('lib'));
gulp.task('clean:es', () => del('es'));
gulp.task('clean', ['clean:cjs', 'clean:es']);
gulp.task('build', ['build:cjs', 'build:es']);
gulp.task('default', ['examples']);