-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathserver.js
48 lines (46 loc) · 1.11 KB
/
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
/*eslint no-console: 0*/
var webpack = require('webpack')
var WebpackDevServer = require('webpack-dev-server')
var port = 8080
var config = {
entry: [
'./register.js',
'babel-polyfill',
'webpack-dev-server/client?http://localhost:' + port,
'webpack/hot/dev-server',
'mocha!./test/test.babel.js'
],
output: {
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015'],
plugins: ['transform-async-to-generator']
}
}
]
},
plugins: []
}
// webpack need this to send request to webpack-dev-server
config.plugins.push(new webpack.HotModuleReplacementPlugin())
// Get line of error in mocha
config.devtool = 'eval-source-map'
// must have
config.output.path = __dirname
var compiler = webpack(config)
var server = new WebpackDevServer(compiler, {
publicPath: '/',
inline: true,
historyApiFallback: false,
stats: { colors: true }
})
server.listen(8080, 'localhost', function () {
console.log('server started at http://localhost:8080')
})