-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Error resolving a CSS file import with custom Webpack rule #627
Comments
https://github.com/css-modules/css-modules-require-hook as i heard this works perfectly! |
I have a similar issue with raw importing markdown.
|
As an additional data point, if I load the page in the browser (showing the error), then edit my source with any change, including adding a blank line, the page live reloads and shows the expected content. But when I reload I get the error page again. |
Also, I was running 2.0.0-beta.0 when I first saw this error and have since upgraded to 2.0.0-beta.9 and still see it. |
It seems like the problem is an imparity between server and client side rendering. You add a webpack loader for some new file type but it doesn't apply on the first render (because SSR doesn't involve bundling via webpack, right?), so it doesn't work. But if you manage to re-render on the client (either by following a link or triggering HMR) it works. If this is correct, the whole extending your webpack config to add additional loaders use case is flawed, because SSR is at the core of Next.js. @rauchg The alternative is to rely on Babel transforms instead of webpack loaders, because those get applied consistently. |
Guys, yes this is a real problem. Just like @skidding mentioned, babel plugins will be the solution for this. (At least in the short term) |
@arunoda No way to get this working on the server? Something like this? https://github.com/halt-hammerzeit/universal-webpack |
Thanks @davidrossjones. I have seen similar projects. But we need find a reliable but performant way to do it. Need to investigate into these tools. |
I have the same problems when I import the bootstrap css. Is there any solution? |
Has any one tried using https://github.com/istarkov/babel-plugin-webpack-loaders with success? |
@noeljackson That should be something interesting. I'd like to play with this. |
@arunoda It seems like
|
Please, have a look at https://github.com/davibe/next.js-css-global-style-test and #544 |
@davibe I found that the repo you linked to loaded the css / scss but caused other issues. For example, I wasn't able to deploy successfully. Really wish there was better support for css imports in some way... And I don't get why |
This is actually a duplicate of #544. Closing this in favor of having the full CSS importing discussion there. |
Hi!
I'm (eventually) attempting to build a PostCSS/cssnext setup on top of Next.js, but somehow importing a CSS file cannot be resolved.
My
pages/index.js
file tries to import thepages/index.css
file (that exists):With the Webpack config:
next.config.js:
results in
output:
Package versions in
package.json
:Do I need to do some extra setup to get the resolving work, or how should I approach this? Thanks!
The text was updated successfully, but these errors were encountered: