-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Cannot import CSS into html component when serving site as Node.js doesn't understand Webpack module types #83
Comments
hi @esauter5 try to require css files instead of importing it, i mean: |
Forgot to mention I had tried that and the same error results so it doesnt seem to be a problem with the |
This is a non-obvious shortcoming with Gatsby right now that your html file gets loaded in Node not Webpack context which means requiring modules that require Webpack fail. I experimented with https://github.com/petehunt/webpack-require in the past to solve this but ran into this problem. I haven't tried it recently so it could be working now. @esauter5 if you'd like to experiment with adding webpack-require support into serve.js that'd be a nice fix. I've run into this same problem and had to do weird workarounds. |
Thanks for the direction @KyleAMathews. I'll play around and see if I can get a PR to submit |
👍🏻
|
@esauter5 pushed fix for this using webpack-require. Will be publishing new release soon. Thanks for your patience! |
Awesome thanks, @KyleAMathews! Sorry I didn't find time to get around to it myself. I worked around it by requiring the css in a different file and then got sidetracked from the project for a bit. |
@esauter5 no worries, I ended up having to do it as part of a bunch of interrelated changes I was making yesterday. Looking forward to other contributions from you ;-) |
@KyleAMathews Slowly making my way through the code, so I'll eventually start pushing :) Probably will get in touch with you this week on Reactiflux about some best practices and stuff. Could use some of your Gatsby knowledge. |
👍 feel free. I'm on Discord most of the time. |
The parent child warnings described in gatsbyjs#83 were the result of us trying to stuff fileNode into Mdx graphql types. As it turns out, this is not necessary because you can query the parent using fragments which more accurately reflect the existence or non-existence of parent types. This also means you could query the base contentful/remote CMS types when trying to add slug fields, etc. Additionally, we unified the code paths that create nodes for all sources and transformers. Since we now use the public APIs, we can have more confidence that people can do everything we can in core when creating new content types.
First, I apologize if this is due to my own ignorance and not knowing enough about how webpack works, but I cannot seem to load any css files.
In
html.jsx
I have:Whenever I run
gatsby serve
, I get an "Illegal token error" on the css file. I've also seen "Unexpected reserved word" errors where javascript reserved words are used in the CSS (like @import). It doesn't appear that it is recognizing it as a css file, but the webpack loaders look good and I've seen the same thing done in gatsby examples.Am I missing something obvious here?
The text was updated successfully, but these errors were encountered: