question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[SSR] A solution for CSS-file-based styling and importing non-js files from webpack

See original GitHub issue

A solution for CSS-file-based styling and importing non-js files from webpack in server side rendering. I have made a package that allows us to import non-js files directly in server side code, without prebundling, and works just like babel-register. I just want to share it to improve other devs experience with SSR: https://github.com/namnm/webpack-register

I also would like to create a PR and include a link in the section that warns users not to use webpack loaders to support for other non-js files. Hope this can help somewhere.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

We can easily require non-js files from webpack bundle, like sass .scss, image .png .jpg, … in our server rendering code.

Current Behavior

Right now, we are not recommended to use CSS-file-based styling and importing non-js from webpack in SSR, due to a bunch of practical issues

Steps to Reproduce (for bugs)

Context

Your Environment

Tech Version
next
node
OS
browser
etc

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
anandmanicommented, Dec 6, 2017

“Right now, we are not recommended to use CSS-file-based styling and importing non-js from webpack in SSR, due to a bunch of practical issues…”

It would be helpful if you could list down a couple of these “practical issues”

0reactions
namnmcommented, Aug 1, 2017

@timneutkens Another thing, is that when we do production serving, next doesnt do any webpack stuff, and it doesnt require the next.config.js file too. So in this case, the asynchronous function to get the webpack config which I mentioned above, doesnt work too.

I think we need to export a file webpack.config.js in our next API

Read more comments on GitHub >

github_iconTop Results From Across the Web

[SSR] A solution for CSS-file-based styling and importing ...
A solution for CSS-file-based styling and importing non-js files from webpack in server side rendering. I have made a package that allows us ......
Read more >
Webpack config for SSR SCSS
Save this question. Show activity on this post. I have a React-TypeScript SSR app where I used SCSS files for my styling.
Read more >
css-loader | webpack - JS.ORG
Disclaimer: css-loader is a third-party package maintained by community members, it potentially does not have the same support, security policy or license as ......
Read more >
Webpack's import() will soon fetch JS + CSS— Here's how ...
A month ago Webpack's creator, Tobias Koppers, unleashed “The big plan” for CSS in Webpack in his article “The new CSS workflow (step1)....
Read more >
Webpack 4 course - part two. Using loaders to handle scss ...
And there you go, now you can import scss files! Files, before being interpreted by the css-loader, will be transpiled from the scss...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found