-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
42 lines (38 loc) · 1.09 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const webpack = require('webpack');
const DevServer = require('webpack-dev-server');
const webpackConfig = require('./webpack.config');
gulp.task('build-webpack', callback => {
webpack(webpackConfig('production'), (err, stats) => {
if (err) {
throw Error('build-webpack', err);
}
if (stats.hasErrors()) {
throw Error('Compile errors have occurred.');
}
callback();
});
});
gulp.task('build-babel', () => {
return gulp.src(['src/**/*', '!src/browser.js'])
.pipe(babel())
.pipe(gulp.dest('lib'));
});
gulp.task('dev-webpack', () => {
const config = webpackConfig('development');
DevServer.addDevServerEntrypoints(config, {
...config.devServer,
host: 'localhost',
});
const compiler = webpack(config);
const server = new DevServer(compiler, config.devServer);
server.listen(4000, 'localhost', err => {
if (err) {
throw err;
}
console.log('Dev server is running.');
});
});
gulp.task('dev', ['dev-webpack']);
gulp.task('build', ['build-babel', 'build-webpack']);