isomorphic-style-loader
isomorphic-style-loader copied to clipboard
Helper method _getCSS() not added on Node server while it works on client side
The isomorphic style loader works fine on client side ( using webpack build), but when I run code on exress server, I get the other style does not have function _getCSS() .
On debugging the style object, its value is the list of styles mentioned in the scss file. So it seems the helper method is not added.
Also, I searched for _getCSS reference on my code, _getCSS & _insertCSS are present in main.js and that is the reason it works on client side. But while compiling on node, I am not sure when(which part of build process) does the helper method _getCSS should get added.
You need self-implemented insertCss
and pass it to context. There is a good example in the README.
server.get('*', (req, res, next) => {
const css = new Set(); // CSS for all rendered React components
const context = { insertCss: (...styles) => styles.forEach(style => css.add(style._getCss())); };
// ...
@abhishek7singh did you resolve this problem? I have the same problem. It seems _getCss
function is not added to style object by ISL loader. I have implemented insertCss
on SSR (like in readme) and it's called fine, where style
– is an object of my component's classnames but without _getCss
method