-
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
configurable output paths #12501
configurable output paths #12501
Conversation
e5b1320
to
06ce2f5
Compare
are the docs should also include the new options? |
probably yes, and there should also be some tests. I'm waiting for more feedback if that's something we want (or the right direction) before putting more time into it :) |
I'm confused as to why the |
d9ea11a
to
0e24bd8
Compare
5b0ad09
to
09f6aa5
Compare
@mathieudutour and I chatted about this a little in Discord. In the interest of explaining the why of where we're coming from, I think it's first helpful to depict the problem that this is solving. @mathieudutour is working on a super-slick Lambda/CI build tool that will clone/fetch repos on changes (to the
This is all fine and dandy, except that Lambda only allows This is a valid, novel use-case for using Gatsby CLI programatically from a lambda. It would be ideal if we could support this use case, and others which require custom build directories and cache directories. Also, most other tools I just spot checked, e.g. Next.js, Vuepress, etc. seem to support a custom build directory. That being said--I don't think the complexity of this PR is the best solution to this problem at this time. WhyComplexityGiven the condition that Gatsby should be able to be configured with a custom build and cache path (which I agree with)--I don't necessarily agree that the solution is one-off slightly misfit APIs, e.g. If we were to introduce something like this--it should be handled automatically, whenever possible. Making this opt-in with a non-intuitive API in some sense makes this incredibly easy for some random plugin to break this workflow entirely. Additionally - as noted, this is a breaking change (for any updated plugin on an older version of Gatsby) that can be mitigated with some guards, but this introduces more complexity to a PR that is already fairly complex and is touching many disparate pieces of functionality. This complexity feeds into my next point: General vs. nicheThis PR introduces a complex, slightly brittle change to Gatsby core for a use case well outside the norm. If we merge this PR, we have to maintain this complexity for all use cases even though it seems apparent that this use case is very much more niche than generally applicable. Could this complexity be better managed at the implementer level (e.g. with tweaks to the lambda, deployment process, etc.) than in the Gatsby core code base? Could this change be better managed (for core maintainers) if we introduce it in a major release with the option for breaking changes? I think it's pretty clear in this case that yeah, the complexity and niche use case makes this better served by implementing some other suggestions, specifically: SuggestionsTrying to rank these in order of complexity/cost/timelines:
I'm well aware this is probably not a decision that you'll be super fond of, so want to make it clear that:
Once-more, if I haven't made it crystal clear, thank you for this PR. We appreciate it--very much! |
Thanks for the detailed answer.
Totally agree that this is weird and should probably go somewhere else. It was simply the easiest, and I'd happily accept suggestions. But that's really a detail.
I don't think it will. It won't change anything for people until one user tries to use a custom path. Then it's about fixing what is effectively a bug in the plugin. The ecosystem can slowly be fixed without breakage for existing users. They shouldn't rely on hardcoded path anyway. That's what I've done preemptively for That's true that it's not really discoverable but that's true for pretty much all the plugin APIs right now.
That's interesting, I couldn't find any way to do that. Because plugins are just node script, they can do anything they want, the paths can be (and often are) dynamically generated so it'd be hard to force anything on them.
That's the thing right, all of those changes feel like workarounds for something that should be in core, and you seem to agree. All other frameworks support that. |
Description
Introduces command line options (also handles env variables) to specify the output directory locations (both
.cache
andpublic
).The two options are
--cache-dir
and--build-dir
(with the respectiveprocess.env.GATSBY_CACHE_DIR
andprocess.env.GATSBY_BUILD_DIR
variables).There shouldn't be any breaking changes if the different packages are updated at the same time but if not, some plugins are now depending on new APIs defined on the
cache
object to access the cache and public folders.It also provides 2 webpack aliases to access both folders (see https://github.com/gatsbyjs/gatsby/pull/12501/files#diff-917ba78a52f29b1a1fe42be34d81fc83R16)
Related Issues
Fixes #1878, #5880