Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koa-webpack for server side rendering #108

Closed
chenlupeng007 opened this issue Feb 16, 2019 · 2 comments
Closed

koa-webpack for server side rendering #108

chenlupeng007 opened this issue Feb 16, 2019 · 2 comments

Comments

@chenlupeng007
Copy link

chenlupeng007 commented Feb 16, 2019

  • 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
Copy link
Owner

That's correct. koa-webpack's purpose is to combine webpack-dev-middleware and webpack-hot-client. It doesn't support SSR.

@chenlupeng007
Copy link
Author

@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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants