Skip to content

Commit f1abcd6

Browse files
committed
Upgrading webpack dev server.
1 parent 22c6111 commit f1abcd6

File tree

4 files changed

+382
-182
lines changed

4 files changed

+382
-182
lines changed

bin/dev.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,41 @@ app.get('*', (req, res) => {
3535
});
3636
});
3737

38-
const server = new WebpackDevServer(webpack(config), {
39-
static: {
40-
directory: path.join(__dirname, '..', 'public'),
41-
},
42-
hot: true,
43-
port: WEBPACK_DEV_SERVER_PORT,
44-
devMiddleware: {
45-
stats: { colors: true },
46-
publicPath: '/',
38+
//console.log(webpack(config));
39+
40+
const server = new WebpackDevServer(
41+
{
42+
static: {
43+
directory: path.join(__dirname, '..', 'public'),
44+
},
45+
hot: true,
46+
host: 'localhost',
47+
port: WEBPACK_DEV_SERVER_PORT,
48+
devMiddleware: {
49+
stats: { colors: true },
50+
publicPath: '/',
51+
},
4752
},
48-
});
53+
webpack(config)
54+
);
4955

56+
(async () => {
57+
await server.start();
58+
console.log(
59+
`${colors.yellow('WebpackDevServer')} is running on ${colors.underline(
60+
`http://localhost:${WEBPACK_DEV_SERVER_PORT}`
61+
)}`
62+
);
63+
})();
64+
/*
5065
server.listen(WEBPACK_DEV_SERVER_PORT, 'localhost', () => {
5166
console.log(
5267
`${colors.yellow('WebpackDevServer')} is running on ${colors.underline(
5368
`http://localhost:${WEBPACK_DEV_SERVER_PORT}`
5469
)}`
5570
);
5671
});
57-
72+
*/
5873
app.listen(PORT, () => {
5974
console.log(`${colors.green('WebApp')} is running on ${colors.underline(`http://localhost:${PORT}`)}`);
6075
});

config/webpack.config-dev.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ const gitRevisionPlugin = new GitRevisionPlugin({
1919
});
2020

2121
module.exports = {
22-
devtool: process.env.NODE_ENV === 'development' ? 'source-map' : 'none',
22+
devtool: process.env.NODE_ENV === 'development' ? 'eval-source-map' : 'none',
2323
entry: path.join(__dirname, '..', 'src/client.js'),
2424
output: {
2525
filename: 'bundle.js',
2626
path: path.join(__dirname, '..', 'public'),
2727
publicPath: '/public/',
28+
//sourceMapFilename: '[name].js.map',
2829
},
2930
mode: 'development',
3031
resolve: {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@
163163
"terser-webpack-plugin": "^5.3.10",
164164
"webpack": "^5.92.0",
165165
"webpack-cli": "^5.1.4",
166-
"webpack-dev-middleware": "^6.1.3",
167-
"webpack-dev-server": "^4.15.2",
166+
"webpack-dev-middleware": "^7.2.1",
167+
"webpack-dev-server": "^5.0.4",
168168
"webpack-isomorphic-tools": "^4.0.0"
169169
},
170170
"packageManager": "[email protected]"

0 commit comments

Comments
 (0)