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

Allow customizing generated file paths for non-HTML files #7808

Closed
nakedible opened this issue Sep 2, 2018 · 4 comments
Closed

Allow customizing generated file paths for non-HTML files #7808

nakedible opened this issue Sep 2, 2018 · 4 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@nakedible
Copy link
Contributor

Summary

Allow customizing the file paths Gatsby generates for JavaScript, CSS and JSON files.

Basic example

Currently, all non-HTML generated files end up at fixed paths in the built directory.

  • JavaScript libraries end up in files like 2-b3d43945f6c7a50aa89b.js
  • JavaScript for pages end up in files like component---src-pages-index-js-d21e28ef0022ceb7ca2f.js
  • CSS for pages end up in files like component---src-pages-index-js.13f388f2be065d96ed97.css
  • Webpack runtime ends up in a file like webpack-runtime-d38689d008fd7c177cbf.js
  • Webpack stats is named webpack.stats.json
  • JSON data ends up in files like static/d/173/path---index-6a9-NZuapzHg3X9TaN1iIixfv1W23E.json

It should be possible to customize these paths, or atleast specify a subdirectory to place these paths in (that is separate from pathPrefix which affects the entire site and not just the non-HTML files).

Motivation

Having the paths fixed makes it difficult to separate paths generated by Gatsby from other paths that might have to co-exist in the same domain. Compare this with WordPress, for example, where all data (for better or worse) is in wp-content or wp-includes.

Using path prefix works if there is only a single subdirectory which should be served by Gatsby, but for example if both /dev/ and /doc/ should be served by Gatsby, and everything else by something different, then the only solution for now would be to make two separate Gatsby sites with different path prefixes, which is quite non-optimal.

@nakedible nakedible changed the title Allow customizing generated file paths Allow customizing generated file paths for non-HTML files Sep 2, 2018
@nakedible
Copy link
Contributor Author

Since generating paths seems to happen all over the place in Gatsby, and path generation method is mostly hardcoded, fixing this to be fully customizable would seem to be quite a large rework.

However, since all places should respect pathPrefix, a simple and stupid solution would be to just break that in to two - pathPrefix and dataPathPrefix. Normally setting pathPrefix would also set dataPathPrefix to the same value, but dataPathPrefix could be overridden invidually. Then it would be simply a case of passing both values to all places and using either __PATH_PREFIX__ or __DATA_PATH_PREFIX__ as appropriate.

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 2, 2019
@gatsbot
Copy link

gatsbot bot commented Jan 2, 2019

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

@gatsbot
Copy link

gatsbot bot commented Jan 13, 2019

This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.

@gatsbot gatsbot bot closed this as completed Jan 13, 2019
@mtsbank
Copy link

mtsbank commented Apr 8, 2020

Hello! What about this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

3 participants