-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-server.js
More file actions
46 lines (38 loc) · 1.23 KB
/
Copy pathdev-server.js
File metadata and controls
46 lines (38 loc) · 1.23 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
const path = require('path');
const isDev = process.env.NODE_ENV === 'development';
const isProd = !isDev;
module.exports = {
hot: isDev,
onListening: function (devServer) {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}
const port = devServer.server.address().port;
console.log('Listening on port:', port);
},
// Specifying a host to use
host: 'localhost',
// Specifying a port number
port: 8989,
// This is the key to our approach
// With a backend on http://localhost/PROJECTNAME/
// we will use this to enable proxying
proxy: {
// Star(*) defines all the valid requests
'*': {
// Specifying the full path to the public folder
// Replace "webpack-devserver-php" with your project folder name
target: `http://localhost/webpack/dist`,
},
},
// Bundle files will be available in the browser under this path
publicPath: path.resolve(__dirname, 'dist'),
static: [
{
// directory: path.join(__dirname, 'app'),
},
{
// directory: path.join(__dirname, 'css'),
},
]
}