-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
executable file
·43 lines (37 loc) · 1.3 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
var gulp = require('gulp');
var gutil = require('gutil');
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var statsConfig = {
colors: true,
chunks: false,
modules: false,
hash: false,
version: false
};
gulp.task('examples:dist', function(cb) {
var webpackConfig = require('./examples/webpack.config');
webpack(webpackConfig, function(err, stats) {
if(err) throw new gutil.PluginError('webpack:build', err);
gutil.log('[webpack:build]', stats.toString(statsConfig));
cb();
});
});
gulp.task('examples:dev', function (cb) {
var webpackConfig = require('./examples/webpack.config')[1];
webpackConfig.devtool = 'eval';
webpackConfig.debug = true;
var htmlWebpackPlugin = webpackConfig.plugins.find(function(plugin) {
return plugin instanceof HtmlWebpackPlugin;
});
htmlWebpackPlugin.options.filename = 'index.html';
// Start a webpack-dev-server
new WebpackDevServer(webpack(webpackConfig), {
publicPath: webpackConfig.output.publicPath,
stats: statsConfig
}).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');
});
});