koa-webpack for server side rendering
chenlupeng007 opened this issue · 2 comments
chenlupeng007 commented
- Node Version: v11.5.0
- yarn Version: 1.13.0
- koa Version: 2.6.2
- koa-wepback Version: 5.2.1
my webpack.config.js is an array which has two elements, one for client rendering, another for server side rendering. so const multiCompilers = webpack(config)
means we get multi-compilers, then
koaWebpack({
compiler: multiCompilers,
devMiddleware: { publicPath: '/' }
})
means we apply koa-webpack for multiCompilers, I know that koa-webpack can deal with multi-compilers, but for server side compiler, it should not apply webpack-hot-client
, it seems that koa-webpack doesn't deal with the problem, it that right?
shellscape commented
That's correct. koa-webpack's purpose is to combine webpack-dev-middleware and webpack-hot-client. It doesn't support SSR.
chenlupeng007 commented
@shellscape
why not change the line in koa-webpack/lib/index.js
:
const hotClient = await getClient(compiler, options);
to
if(compiler.compilers) {
const hotClient = await getClient(compiler.compilers.find(compiler => compiler.name === 'client'), options);
} else {
const hotClient = await getClient(compiler, options);
}