-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
72 lines (61 loc) · 1.63 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
'use strict';
var gulp = require('gulp');
var babel = require('gulp-babel');
var WebpackDevServer = require("webpack-dev-server");
var webpack = require("webpack");
gulp.task('recompile', function() {
return gulp.src('server-js/*.js*')
.pipe(babel({
stage: 1,
optional: ['runtime']
}))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function() {
gulp.watch('server-js/*.js*', ['recompile']);
});
gulp.task('webpack', function() {
});
gulp.task('default', ['recompile', 'watch', 'webpack']);
gulp.task('webpack', function() {
var config = {
entry: [
'webpack/hot/only-dev-server',
__dirname + '/client-js/index.js' // Your appʼs entry point
],
output: {
path: __dirname + '/client-dist/',
publicPath: "/",
filename: 'bundle.js',
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules\//,
loaders: ['react-hot', 'babel-loader?stage=1&optional=runtime']
}]
},
devtool: 'source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
};
var server = new WebpackDevServer(webpack(config), {
// webpack-dev-server options
// or: contentBase: "http://localhost/",
hot: true,
// Enable special support for Hot Module Replacement
// Page is no longer updated, but a "webpackHotUpdate" message is send to the content
// Use "webpack/hot/dev-server" as additional module in your entry point
// Note: this does _not_ add the `HotModuleReplacementPlugin` like the CLI option does.
watchOptions: {
aggregateTimeout: 300,
poll: 100
},
stats: {
colors: true
}
});
server.listen(12346, "localhost", function() {});
});