-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
48 lines (40 loc) · 1.16 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
var pkg = require('./package.json'),
gulp = require('gulp'),
webpack = require('webpack'),
WebpackDevServer = require('webpack-dev-server'),
eslint = require('gulp-eslint');
const webpackConfig = require('./webpack.config.js'),
devConfig = webpackConfig(true),
prodConfig = webpackConfig(false, { banner: banner() });
function banner() {
return `/*
* ${pkg.name} ${pkg.version}
* ${pkg.homepage}
*
* The MIT License (MIT)
* Copyright (c) 2018 Hyun-Seok.Kim, [email protected]
*/
`;
}
// tasks
gulp.task('webpack-dev-server', function() {
const compiler = webpack(devConfig);
var server = new WebpackDevServer(compiler, devConfig.devServer);
server.listen(devConfig.devServer.port, 'localhost', err => {
if (err) console.error('[webpack-dev-server failed to start :', err);
});
});
gulp.task('build:dev', function(callback) {
const compiler = webpack(devConfig);
compiler.run((error, stats) => {
if (error) throw new Error(error);
callback();
});
});
gulp.task('build', function(callback) {
const compiler = webpack(prodConfig);
compiler.run((error, stats) => {
if (error) throw new Error(error);
callback();
});
});