-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (65 loc) · 1.93 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
74
75
76
77
78
var gulp = require('gulp');
var HtmlWebpackPlugin = require('html-webpack-plugin')
var path = require('path');
var WebpackDevServer = require("webpack-dev-server");
var webpack = require('webpack')
var gutil = require('gutil')
var del = require('del');
var absPath = function(pathString){
return path.join(__dirname, pathString);
}
var config = {
entry: {
client : "./src/index.js"
},
output: {
path : absPath("/dist"),
filename : "[chunkhash].js",
chunkFilename : "[id].[chunkhash].js"
},
module: {
loaders: [
{
test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$/,
loader: "url-loader?limit=10000"
},
]
},
resolve: {
alias: {
// fluxmax : absPath('../../src/index'),
'event-emitter' : 'wolfy87-eventemitter',
},
},
plugins: [
new HtmlWebpackPlugin({
template : './index.html',
})
],
devtool: 'eval',
debug: true,
}
gulp.task("default", ["webpack-dev-server"]);
gulp.task("webpack-dev-server", function(callback){
// Start a webpack-dev-server
new WebpackDevServer(webpack(config), {
contentBase : './dist',
stats: {
colors: true
},
watch: 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");
});
});
gulp.task("build", function(callback){
console.log(absPath('./dist/**'))
del(absPath('./dist/**'));
webpack(config, function(err, stats) {
if(err) throw new gutil.PluginError("webpack:build", err);
gutil.log("[webpack:build]", stats.toString({
colors: true
}));
});
});