|
| 1 | +const path = require("path"); |
1 | 2 | const { merge } = require("webpack-merge");
|
2 |
| -const commonConfiguration = require("./webpack.common.js"); |
3 | 3 | const portFinderSync = require("portfinder-sync");
|
4 |
| - |
5 |
| -const infoColor = (_message) => { |
6 |
| - return `\u001b[1m\u001b[34m${_message}\u001b[39m\u001b[22m`; |
7 |
| -}; |
| 4 | +const commonConfiguration = require("./webpack.common.js"); |
8 | 5 |
|
9 | 6 | module.exports = merge(commonConfiguration, {
|
10 | 7 | mode: "development",
|
| 8 | + |
11 | 9 | devServer: {
|
12 | 10 | host: "localhost",
|
13 | 11 | port: portFinderSync.getPort(8080),
|
14 |
| - contentBase: "./dist", |
15 |
| - watchContentBase: true, |
| 12 | + static: [ |
| 13 | + { |
| 14 | + directory: path.resolve(__dirname, "dist"), |
| 15 | + watch: true, |
| 16 | + }, |
| 17 | + { |
| 18 | + directory: path.resolve(__dirname, "static"), |
| 19 | + staticOptions: {}, |
| 20 | + publicPath: "/static-public-path/", |
| 21 | + serveIndex: true, |
| 22 | + watch: true, |
| 23 | + }, |
| 24 | + ], |
16 | 25 | proxy: {
|
17 |
| - "/socket.io": { target: "ws://localhost:3000" }, |
18 |
| - "/api": { target: "ws://localhost:8080" }, |
| 26 | + "/socket.io": { target: "http://localhost:3000", ws: true }, |
| 27 | + "/api": { target: "http://localhost:8080", ws: true }, |
19 | 28 | },
|
20 | 29 | open: true,
|
21 | 30 | https: false,
|
22 |
| - useLocalIp: false, |
23 |
| - disableHostCheck: true, |
24 |
| - overlay: true, |
25 |
| - noInfo: true, |
26 |
| - after: function (app, server, compiler) { |
27 |
| - const port = server.options.port; |
28 |
| - const https = server.options.https ? "s" : ""; |
29 |
| - const domain = `http${https}://localhost:${port}`; |
30 |
| - |
31 |
| - console.log(`Project running at:\n - ${infoColor(domain)}`); |
| 31 | + allowedHosts: "all", |
| 32 | + onAfterSetupMiddleware: function (devServer) { |
| 33 | + devServer.app.get("/some/path", function (req, res) { |
| 34 | + res.json({ custom: "response" }); |
| 35 | + }); |
| 36 | + }, |
| 37 | + client: { |
| 38 | + logging: "info", |
| 39 | + overlay: { |
| 40 | + errors: true, |
| 41 | + warnings: true, |
| 42 | + }, |
| 43 | + progress: true, |
| 44 | + reconnect: true, |
| 45 | + webSocketTransport: "ws", |
| 46 | + webSocketURL: { |
| 47 | + hostname: "localhost", |
| 48 | + pathname: "/ws", |
| 49 | + port: 8080, |
| 50 | + }, |
32 | 51 | },
|
33 | 52 | },
|
34 | 53 | });
|
0 commit comments