-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
64 lines (56 loc) · 1.64 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import gulp from 'gulp';
import babel from 'gulp-babel';
import mocha from 'gulp-mocha';
import gutil from 'gulp-util';
import webpack from 'webpack';
import webpackConfig from './webpack.config.babel';
import WebpackDevServer from 'webpack-dev-server';
gulp.task('default', ['webpack']);
gulp.task('babel', () => {
return gulp.src(['src/*.js','src/*/*.js'])
.pipe(babel())
.pipe(gulp.dest('target'));
});
gulp.task('test', ['babel'], () => {
return gulp.src('test/*.js')
.pipe(mocha())
.on('error', () => {
gulp.emit('end');
});
});
gulp.task('watch-test', () => {
return gulp.watch(['src/**', 'test/**'], ['test']);
});
gulp.task('webpack', ['test'], function(callback) {
var myConfig = Object.create(webpackConfig);
myConfig.plugins = [
//new webpack.optimize.DedupePlugin(),
//new webpack.optimize.UglifyJsPlugin()
];
// run webpack
webpack(myConfig, function(err, stats) {
if (err) throw new gutil.PluginError('webpack', err);
gutil.log('[webpack]', stats.toString({
colors: true,
progress: true
}));
callback();
});
});
gulp.task('server', ['webpack'], function(callback) {
// modify some webpack config options
var myConfig = Object.create(webpackConfig);
myConfig.devtool = 'eval';
myConfig.debug = true;
// Start a webpack-dev-server
new WebpackDevServer(webpack(myConfig), {
publicPath: '/' + myConfig.output.publicPath,
stats: {
colors: true
},
hot: true
}).listen(8080, 'localhost', function(err) {
if(err) throw new gutil.PluginError('webpack-dev-server', err);
gutil.log('[webpack-dev-server]', 'http://localhost:8080/webpack-dev-server/index.html');
});
});