How can I have a third parallel compilation for the WebSockets server? #1672
Answered
by
fivethreeo
silviubogan
asked this question in
Q&A
Replies: 5 comments 13 replies
-
Would have to add a extra start server plugin that starts a different entrypoint. |
Beta Was this translation helpful? Give feedback.
0 replies
-
// razzle.config.js
'use strict';
const StartServerPlugin = require('razzle-start-server-webpack-plugin');
module.exports = {
modifyWebpackConfig(opts) {
const config = opts.webpackConfig;
const options = opts.options.webpackOptions;
if (opts.env.target === 'node') {
config.entry.wsserver = ['./src/server/ws.tsx'];
if (opts.env.dev) {
config.entry.wsserver.unshift(
`${require.resolve('webpack/hot/poll')}?300`
);
// Pretty format server errors
config.entry.wsserver.unshift(
require.resolve('razzle-dev-utils/prettyNodeErrors')
);
config.plugins.push(
new StartServerPlugin(
Object.assign(options.startServerOptions, {
entryName: 'wsserver'
})
)
);
}
}
return config;
},
}; |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
fivethreeo
-
Hm, it may be startserver plugin is not thread safe. |
Beta Was this translation helpful? Give feedback.
4 replies
-
Use razzle-start-server-webpack-plugin |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A big part of the WS server is already written: it uses TypeScript, the same path alias as for the main server and preferably ES6 import syntax. I want to be able to watch-build and run it separately for easier debugging. I just moved the code into its own ws.tsx file (I tested it a little bit before although it still has some bugs I must solve) and I do not know what to do next in regards to using the same path aliases.
I put that ws.tsx file inside the server/ directory which contains the main server in index.tsx.
Any help is greatly appreciated.
Thanks!
Update 1
Further information: the contents of tsconfig.json:
Beta Was this translation helpful? Give feedback.
All reactions