Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

fix support server side usage - #115

Closed
magalhas wants to merge 2 commits into
webpack:masterfrom
jscrambler:master
Closed

magalhas wants to merge 2 commits into
webpack:masterfrom
jscrambler:master

Conversation

@magalhas

Copy link
Copy Markdown

I'm using local scopes and I wasn't able to render on the server side because of style loader. This little fix solved all my problems 👍

@randycoulman

Copy link
Copy Markdown

This little fix works great for us as well. Here's more context on how we're using it: http://randycoulman.com/blog/2016/03/22/testing-with-mocha-and-webpack/ (reference to this issue at the very end, under Gotchas).

@sokra

sokra commented Mar 24, 2016

Copy link
Copy Markdown
Member

see last section in this chapter: https://github.com/webpack/css-loader#local-scope

use css/locals when using SSR.

@sokra sokra closed this Mar 24, 2016
@magalhas

Copy link
Copy Markdown
Author

@sokra does that work if I don't use ExtractTextPlugin and rely on shipping my CSS inside JS? I'm asking because with the PR it worked perfectly, I guess the css/locals solution will as well, just want to be sure of it :)

@sokra

sokra commented Mar 24, 2016

Copy link
Copy Markdown
Member

css/locals just returns the local to class mappings, without style tags, CSS and such stuff, which is not needed for server-side rendering. It works with CSS inside JS, but that is usually not used in combination with server-side rendering because you either get FOUC or blocking JS.

@magalhas

Copy link
Copy Markdown
Author

I was asking for development. Thank you for clarifying!

@sokra

sokra commented Mar 25, 2016

Copy link
Copy Markdown
Member

I was asking for development.

Then it's fine of course... ;)

randycoulman added a commit to CodingZeal/react-boilerplate that referenced this pull request Mar 25, 2016
We had been using a specific commit of style-loader that matched an
outstanding PR that made it work in the node environment
(webpack/style-loader#115).

That PR was rejected with a suggestion to use `css-loader/locals`
instead of the style-loader, so that’s what I’ve done here, which
allows us to go back to the stock version of style-loader.

I reverted the change that pulled the SCSS handling up to the base
webpack config as there is now much less duplication.

I ran into a bunch of strange behavior along the way, but what’s here
seems to work well:

* The decorated style names have an extra `_-_-` prefix on them that
doesn’t show up in the browser environment.
* Using the trailing `!sass` on the loader definition resulted in a
random suffix of either `—sass` or `-sass` or none at all being added
to the style names, and it’s inconsistent enough to potentially make
specs fail.  Moving the other loaders to a separate element of the
array resolves this.
* I found that I don’t actually seem to need the sass loader at all,
and that makes no sense to me at all.  I’ve left it in because it seems
like it really needs to be there, but I am very confused by what I saw.
@peterh32

peterh32 commented May 1, 2018

Copy link
Copy Markdown

So... this never got merged? And style-loader is still broken for server-side rendering?

@alexander-akait

Copy link
Copy Markdown
Member

@peterh32 style-loader works good with SSR. Please don't write about your problem in old closed issue,
create a new issue with description and minimally reproducible test repo. Thanks!

@jsf-clabot

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

1 similar comment
@jsf-clabot

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@alsun

alsun commented Aug 20, 2019

Copy link
Copy Markdown

It look like in 1.0.0 it's come back 😢

@alexander-akait

Copy link
Copy Markdown
Member

@alsun no

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants