-
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
Whitelist page types + add image loader #357
Conversation
Also remove now unneeded null-loader config for various assets.
This will require a breaking release as it could conflict with existing webpack configs + requires installation of image-webpack-loader (if you want to use image loaders). |
@KyleAMathews I've been looking through the linked issues from this PR but couldn't find a solution. Sorry if this has been answered elsewhere, but is there a simple way to say: I don't want .json files to get rendered as pages, but just copy them as a plain file to the public folder? Right now, it seems that it's treating it as a page and doing weird things like converting it to a folder where it copies the other image assets. I'm running version 0.12.19. Any help would be appreciated. I'm still trying to figure out how to properly configure and modify Webpack, and this particular issue seems to be impossible to solve with my current knowledge of Gatbsy internals. |
@marcelkalveram this is something that needs clarified — there's a proposal to add a |
@KyleAMathews Is there any way to customize this whitelist? I'm using
Which is causing troubles when applyed to a page:
Because Gatsby is trying to load As a temporary fix, I'm currently declaring styled-components inside the page file, but I'm looking to only load I saw in the project's sources that an underscore would prevent the file to be loaded as a page. Is that a reliable feature ? |
Most people put components in their own directory at |
Indeed, my components are located in Thanks for the confirmation about the underscore naming 👍 |
Gatsby uses
require.context
from Webpack to require pages as modules from the/pages/
directory.Previously to this PR, Gatsby would try to require everything inside pages which meant Webpack would throw an error when there was a file within
/pages/
without a loader setup for it. A number of people ran into this.So as a side-effect, this also meant Gatsby couldn't ship with image loaders as I had a number of sites with images in pages (these are copied to
/public/
on build).So this PR fixes both problems. Now there's a whitelist of file types that are treated as potential pages and it adds a default loader for images.
Fixes #208, #287, and #18