-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.dev.js
More file actions
55 lines (53 loc) · 1.63 KB
/
webpack.dev.js
File metadata and controls
55 lines (53 loc) · 1.63 KB
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
const webpack = require('webpack');
const merge = require('webpack-merge');
const WebpackDevServer = require('webpack-dev-server');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const colors = require('colors/safe');
const portfinder = require('portfinder');
const common = require('./webpack.common.js');
const { url } = require('./package.json');
portfinder.basePort = 4000;
portfinder.getPort((err, finalPort) => {
if (err) {
callback(err); // eslint-disable-line
}
const compiler = webpack(
merge(common, {
entry: {
game: [
// Live-reload
`webpack-dev-server/client?http://localhost:${finalPort}`
]
},
output: {
chunkFilename: 'chunk-[name]-[chunkhash].js'
},
devtool: 'source-map',
mode: 'development',
plugins: [
new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: {
messages: [
`Game is running here ${colors.bold(colors.blue(`http://localhost:${finalPort}`))}`
],
notes: [
`${colors.inverse(`Project url - ${url}`)}`,
`phaser docs - ${colors.cyan('https://photonstorm.github.io/phaser3-docs/')}`,
`phaser example - ${colors.rainbow('https://labs.phaser.io/')}`
]
}
})
]
})
);
const server = new WebpackDevServer(compiler, {
https: false,
quiet: true,
stats: {
colors: true
}
});
server.listen(finalPort, null, () => {
// console.log(`Project is running at: ${colors.bold(colors.green('http://localhost:' + finalPort))}`);
});
});