-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.babel.js
47 lines (42 loc) · 1.24 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import ghPages from 'gulp-gh-pages';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import productionConfig from './webpack.production.config';
import devServerConfig from './webpack.dev-server.config';
import eslint from 'gulp-eslint';
gulp.task('lint', () => (
gulp.src('src/**/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
));
gulp.task('serve', () => {
new WebpackDevServer(webpack(devServerConfig), {
hot: true,
publicPath: devServerConfig.output.publicPath,
stats: {
colors: true
}
}).listen(devServerConfig.port, 'localhost', (err) => {
/* eslint-disable no-console */
if (err) {
console.log(err);
return;
}
console.log(`Listening at localhost: ${devServerConfig.port}`);
/* eslint-enable no-console */
});
});
gulp.task('build', ['lint'], done => {
webpack(productionConfig).run((err, stats) => {
/* eslint-disable no-console */
err && console.log('Error', err);
stats && console.log(stats.toString({ colors: true }));
done && done();
/* eslint-enable no-console */
});
});
gulp.task('deploy', ['build'], () =>
gulp.src('./dist/**/*').pipe(ghPages({ force: true }))
);