-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
51 lines (44 loc) · 1.55 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
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const webpack = require('webpack');
const del = require('del');
const gutil = require('gulp-util');
const WebpackDevServer = require('webpack-dev-server');
gulp.task('clean', function (callback) {
del(['build'], callback);
});
// Note: To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
gulp.task('lint', function gulpLint() {
return gulp.src(['src/**/*.jsx', 'src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('dev', ['clean', 'webpack:dev'], function () {
gulp.watch(['src/**/*'], ['webpack:build-dev']);
});
gulp.task('build', ['clean', 'webpack:build']);
gulp.task('webpack:dev', function (callback) {
var webpackConfig = require('./configs/webpack/development.config');
webpack(Object.create(webpackConfig)).run(function (err, stats) {
if (err) throw new gutil.PluginError('webpack:dev', err);
gutil.log('[webpack:dev]', stats.toString({
colors: true
}));
callback();
});
});
gulp.task('webpack:build', function (callback) {
var webpackConfig = Object.create(require('./configs/webpack/production.config'));
webpack(webpackConfig, function (err, stats) {
if (err) throw new gutil.PluginError('webpack:build', err);
gutil.log('[webpack:build]', stats.toString({
colors: true
}));
callback();
});
});
gulp.task('default', ['lint'], function gulpDefault() {
// This will only run if the lint task is successful...
});