-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
49 lines (43 loc) · 1.03 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
import gulp from 'gulp';
import webpack from 'webpack-stream';
import WebpackCore from 'webpack';
import connect from 'gulp-connect';
import watch from 'gulp-watch';
import config from './webpack.config.js';
gulp.task('build', () => {
return gulp.src('.')
.pipe(webpack(config))
.pipe(gulp.dest('public/'));
});
gulp.task('serve', ['build'], () => {
gulp.start('watch');
connect.server({
name: 'dev',
root: ['.'],
port: 8000,
livereload: true
});
});
gulp.task('watch', () => {
return watch('src/**/*', () => {
gulp.start('build');
});
});
gulp.task('prod', () => {
let myConfig = Object.create(config);
myConfig.plugins = myConfig.plugins.concat(
new WebpackCore.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new WebpackCore.optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
new WebpackCore.optimize.DedupePlugin()
);
return gulp.src('.')
.pipe(webpack(myConfig))
.pipe(gulp.dest('public-prod/'));
});
gulp.task('default', ['serve'])