-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.dev.server.js
81 lines (69 loc) · 2.64 KB
/
webpack.dev.server.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
79
80
81
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.dev.config.js');
var entry = config.entry;
for (var entryname in entry) {
entry[entryname].unshift('webpack/hot/dev-server');
entry[entryname].unshift("webpack-dev-server/client?http://localhost:8080/");
}
console.log('devserver: ', config.entry);
var compiler = webpack(config);
var server = new WebpackDevServer(compiler, {
// webpack-dev-server options
// publicPath: config.output.publicPath,
contentBase: "build/",
// Can also be an array, or: contentBase: "http://localhost/",
hot: true,
inline: true,
// Enable special support for Hot Module Replacement
// Page is no longer updated, but a "webpackHotUpdate" message is sent 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.
// historyApiFallback: false,
// Set this as true if you want to access dev server from arbitrary url.
// This is handy if you are using a html5 router.
// compress: false,
// Set this if you want to enable gzip compression for assets
// proxy: {
// "**": "http://localhost:9090"
// },
// Set this if you want webpack-dev-server to delegate a single path to an arbitrary server.
// Use "**" to proxy all paths to the specified server.
// This is useful if you want to get rid of 'http://localhost:8080/' in script[src],
// and has many other use cases (see https://github.com/webpack/webpack-dev-server/pull/127 ).
// setup: function(app) {
// Here you can access the Express app object and add your own custom middleware to it.
// For example, to define custom handlers for some paths:
// app.get('/some/path', function(req, res) {
// res.json({ custom: 'response' });
// });
// },
// pass [static options](http://expressjs.com/en/4x/api.html#express.static) to inner express server
// staticOptions: {
// },
// clientLogLevel: "info",
// Control the console log messages shown in the browser when using inline mode. Can be `error`, `warning`, `info` or `none`.
// webpack-dev-middleware options
quiet: false,
noInfo: false,
lazy: true,
// filename: "bundle.js",
filename: config.output.filename,
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
// It's a required option.
publicPath: config.output.publicPath,
// headers: { "X-Custom-Header": "yes" },
stats: { colors: true },
// devtool: 'eval',
devtool: 'cheap-module-eval-source-map',
});
server.listen(8080, "localhost", function(error, result){
if (error) {
console.log(err);
}
console.info('Listen at localhost:8080');
});
// server.close();