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

SSR "context.styles" is not defined on webpack 4 #11794

Open
dszymon opened this issue Nov 26, 2020 · 0 comments
Open

SSR "context.styles" is not defined on webpack 4 #11794

dszymon opened this issue Nov 26, 2020 · 0 comments

Comments

@dszymon
Copy link

dszymon commented Nov 26, 2020

Version

2.5.22

Reproduction link

https://github.com/Szymon-D/VueSsrStylesReproduction

Steps to reproduce

  1. Clone the repository
  2. Run npm install
  3. Run npm run build
  4. Run npm start
  5. Open http://localhost:8080
  6. Check head tag, there are no inline styles from the current route

What is expected?

There should be style tags with data-vue-ssr-id attribute

What is actually happening?

Output includes only link tags to external CSS files


The issue is related to replacement of extract-text-webpack-plugin with extract-css-chunks-webpack-plugin.
It seems that with newer plugins, vue-style-loader doesn't get called in all cases where it would as the value of the fallback option to the legacy plugin.
There is no styles field on the context after rendering the app, as you can see here

Object.defineProperty(userContext, 'styles', {

it's defined only in case if there's a _renderStyles function, which comes from the vue-style-loader
https://github.com/vuejs/vue-style-loader/blob/477c25e1a506c54e18cb443f7981aed6d4e80e65/lib/addStylesServer.js#L16

@dszymon dszymon changed the title "context.styles" is not defined on webpack 4 SSR "context.styles" is not defined on webpack 4 Nov 26, 2020
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

1 participant