-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathgulpfile.js
73 lines (59 loc) · 1.49 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
/**
* Module dependencies
*/
var gulp = require('gulp'),
gutil = require('gulp-util'),
path = require('path'),
del = require('del'),
open = require('open'),
webpack = require('webpack'),
WebpackDevServer = require('webpack-dev-server'),
webpackConfig = require('./webpack.config.js');
gulp.task('webpack', function (callback) {
webpack(webpackConfig, function (err, stats) {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack]', stats.toString({
colors: true
}));
callback();
});
});
gulp.task('webpack-dev-server', function (callback) {
new WebpackDevServer(webpack(webpackConfig), {
contentBase: path.join(__dirname, 'www'),
stats: {
colors: true
}
}).listen(8080, 'localhost', function (err) {
if (err) {
throw new gutil.PluginError('webpack-dev-server', err);
}
var startUrl = 'http://localhost:8080/webpack-dev-server/index.html';
open(startUrl);
gutil.log('[webpack-dev-server]', startUrl);
});
});
gulp.task('clean', function (cb) {
del([
'www/**/*',
'!www/.gitignore'
], {
dot: true
}, cb);
});
gulp.task('clean-all', function (cb) {
del([
'www/**/*',
'!www/.gitignore',
'node_modules',
'bower_components'
], {
dot: true
}, cb);
});
gulp.task('install', ['webpack']);
gulp.task('watch', ['webpack-dev-server']);
gulp.task('default', ['install']);