Skip to content

Commit

Permalink
fix: update dev server to work with v4+ of webpack-dev-middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
dyersituations committed Jul 9, 2024
1 parent 5469517 commit fc2ca76
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions server/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ threadLoader.warmup({
]);

// webpack setup
const clientCompiler = webpack(clientConfig);
const clientCompiler = webpack({
...clientConfig,
devServer: {
hot: false, // Ensures that HMR works as expected
},
});
const serverCompiler = webpack(serverConfig);
const devMiddleware = webpackDevMiddleware(clientCompiler, {
logLevel: 'silent',
stats: false,
stats: 'none', // Hides compilation logs
publicPath: clientConfig.output.publicPath,
watchOptions: {
poll: 1000
}
// serverSideRender: true,
});
const hotMiddleware = webpackHotMiddleware(clientCompiler, {
path: '/__ui_hmr',
log: () => {}
log: () => { }
});

// file reader helper
Expand Down Expand Up @@ -135,11 +135,11 @@ chokidar.watch(path.resolve(__dirname, 'index.template.html')).on('change', () =
// update when the client manifest changes
clientCompiler.hooks.done.tap('done', rawStats => {
// abort if there were errors
const stats = rawStats.toJson();
if (stats.errors.length) return;
const stats = rawStats?.toJson();
if (stats?.errors?.length) return;

// read client manifest from dev-middleware filesystem
clientManifest = JSON.parse(readFile(devMiddleware.fileSystem, 'vue-ssr-client-manifest.json'));
clientManifest = JSON.parse(readFile(devMiddleware.context.outputFileSystem, 'vue-ssr-client-manifest.json'));
updateHandler();
});

Expand Down Expand Up @@ -198,7 +198,7 @@ app.use(logger.errorLogger);
app.use(logger.fallbackErrorHandler);

// start server
app.listen(port, () => console.info(JSON.stringify({
app.listen(port, () => console.info(JSON.stringify({
meta: {},
level: 'log',
message: `dev-server started at localhost:${port}`
Expand Down

0 comments on commit fc2ca76

Please sign in to comment.