Skip to content
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

absolute resolves for gatsby config files #1195

Merged
merged 1 commit into from
Jun 19, 2017

Conversation

craigmulligan
Copy link

I'm running gatsby from another directory, so I need this to be an absolute path to properly cache bust.

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit 7f872f7

https://deploy-preview-1195--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit 7f872f7

https://deploy-preview-1195--gatsbygram.netlify.com

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit 7f872f7

https://deploy-preview-1195--gatsbyjs.netlify.com

@KyleAMathews
Copy link
Contributor

So... we've never supported running Gatsby from a different directory as it complicates a lot of code for what seems like a unnecessary reason.

If you do want to run Gatsby from another directory, I'd suggest writing a script which just changes directory for you. Would that work?

@craigmulligan
Copy link
Author

I'll explain my use-case to give some context.

So I have a project that you can run on git repo and it generates a website, it's currently using gatsby as the engine to generate the site, but I have my own cli to mimic many of the gatsby functionalities and to implement some functionalities unique to what I need (like ejecting specific components/pages/layouts). This my source repo doesn't need to have any of the /src/... conventions unless it's making customisations to the templates.

When I run landr develop/build it writes, a new gatsby-config unique for the paths of process.cwd() see here.

So all sites are built from the landr package directory in node_modules, but the plugins have access markdown files and data form the process.cwd() directory.

It's working quite nicely, because the gatsby commands all seem to respect the program.directory they are given, except in this case the cache function expects gatsby-config.js to be the the CWD.

This fixes that, but doesn't change standard gatsby behaviour because cwd is usually program.directory.

Let me know if you need further explanation on any of the above :)

@KyleAMathews
Copy link
Contributor

Landr is so cool ❤️

This is an awesome use case for Gatsby. And really love that you implemented the eject functionality. Really keen to see how that goes. You were the one right I talked with on Discord a few weeks ago about Gatsby themes?

Are you publishing your transformer plugins to NPM? Want to add a plugin search tool to gatsbyjs.org sooner than later for both official/community plugins.

@KyleAMathews
Copy link
Contributor

On the PR — I'm surprised things are just working for you as in the past, this use case proved tricky but perhaps things magically fixed themselves somewhere along the line :-) In any case, running gatsby commands from other directories is still not officially supported but no harm in merging PRs from you and others that want to make this use case work.

@KyleAMathews KyleAMathews merged commit 0eebe40 into gatsbyjs:1.0 Jun 19, 2017
@craigmulligan
Copy link
Author

Yea I saw one or two instances in the code that referenced process.cwd(), but everything is working so far 🙉. I haven't published the plugins yet, still figuring out exactly how they will work, but will let you know when I do publish em.

Re: landr yea I think the idea has legs, will keep you updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants