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

Added a CLI flag that lets you change the default pages path from ./pages to something else #391

Closed
wants to merge 2 commits into from
Closed

Conversation

steveluscher
Copy link

So, this is not necessarily a good idea, or even something desirable, but I'd like to put up this PR for posterity/discussion.

This PR adds a CLI flag that you can use to change the default ‘pages path’ from ./pages to something else.

gatsby develop --pages-path ./content

This was originally developed so that I could vacuum up pages from a location outside the site root (ie. to use the same site builder to build sites from different ‘pages’ sources). Unfortunately, as soon as you start to require files outside the project root, everything starts to fall apart (eg. Webpack can no longer resolve ‘babel-loader’ because node_modules is not in the path).

Feel free to make this better, provide an argument for why the pages path shouldn't be configurable, or simply close this.

@KyleAMathews
Copy link
Contributor

Your experience has validated a growing conclusion that Webpack/Babel, while powerful, have a lot of hidden assumptions with really really spiky edges. I like Webpack and appreciate how much it's enabled me to do but I totally get people who hate it. It doesn't protect you very well. Anyway, one of spiky edges seems to be don't pull from outside the webpack/babel root — which you ran into and which I just ran into trying to setup a Gatsby site for react-spinkit. The react component requires the css for the module but when I tried importing that component into the Gatsby site (in a www subdirectory) Webpack fell apart loading the css.

I think instead what we should do is add a plugin that can copy src files into Gatsby. So in the "create a docs site for a open source project" scenario like react-spinkit, Gatsby on starting would just copy the src directory into a directory (hidden by .gitignore) and go from there. The plugin would include a watcher so while you're developing the component code, the docs site would still hot-reload.

@MoOx
Copy link

MoOx commented Aug 15, 2016

I think from a user point of view, not having the possibility to change the "content" folder very easily is really weird. Phenomic handle this via a simple option (that can obviously be configured via CLI like all other options).

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Aug 15, 2016

@MoOx that option is still on the table. My comment was specifically directed towards @steveluscher's (and mine) particular use case, pulling in files from outside the site root.

@benstepp
Copy link
Contributor

I think this is something that doesn't belong on the CLI, but rather the site's configuration. It doesn't make sense to have to remember which flags you put into the CLI for a specific project. I think for now this config option should live in gatsby-node.js.

Plus, what happens when gatsby can support more than just a file system as a source? The information required to process a source for the gatsby pipeline is almost assuredly more than something that can be passed as a simple string in a command line flag.

sources: [
  new FileSystemDirectory('pages'),
  new ApiSomewhere(),
]

@KyleAMathews
Copy link
Contributor

And yeah, after banging my head against this stupid little site for an hour or whatever, I just copied react-spinkit's src into the Gatsby folder and it just worked. Sheesh.

@KyleAMathews
Copy link
Contributor

@benstepp +1. I'll be making some specific proposals soon. Prototyping stuff at the moment...

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.

4 participants