-
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
feat(gatsby-plugin-sass): add option to enable resolve-url-loader #14272
Conversation
Cool 😎 ! Any reason why we shouldn't enable this by default? Any possible breaking scenarios? |
Well, sass and sass-loader do not provide url rewriting by default, they recommend using resolve-url-loader to solve that. So, the expected behavior is using paths in url() relative to the entry file and I would not change defaults as it can confuse plugin users. It would break also projects using images already created with those paths relatives to the entry file and not relative to the file where the image is loaded itself. Activating it will benefit though users trying to generate documentation from external projects which uses relative url() to the file without having to modify their projects code (that is mainly the reason I need it). Also users generating new documentation with Gatsby from scratch will benefit by being able to add short relative paths as url(./image_name.svg) and not having to remember the main entry file. |
Some anecdotal justification for this change: I've just picked up gatsbyjs for the first time for a side project (cause it looks great!), and have started to migrate my site to it. This is the first issue I faced with gatsby and I wasn't ready to hack around the problem, and until seeing this PR I was about to drop it and try a different framework altogether! |
Running prettier on README
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When green I'll merge this one.
sorry for keeping you waiting @carlosruana! This slipped my mind.
Holy buckets, @carlosruana — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
…tsbyjs#14272) * Using resolve-url-loader if configured in the options * Documenting how to use resolve-url-plugin plugin * Fixing small typo * Fixing small typo * Fixing prettier checks * Using backtick quotes for strings * resolve-url-loader needs sass-loader to have sourceMap activated * Updating documentation * Updating documentation about sourceMap * chore: format * Update README.md * Update README.md Running prettier on README * chore: format
Description
Currently plugin just resolves url() paths relative to the main sass entry file.
resolve-url-loader adds the ability to use paths relative to the file where the url() is being used.
By default if not configured in the gatsby-plugin-sass, the loader is not being used, but you can activate it and also configure resolve-url-loader plugin with the options it provides.
Usage has been also documented in the README.md of the gatsby-plugin-sass
Related Issues
Fixes #7776, #6438