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

Make a custom directory accessible to GatsbyJS for development and build #13503

Closed
insmac opened this issue Apr 19, 2019 · 3 comments
Closed
Labels
stale? Issue that may be closed soon due to the original author not responding any more. type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@insmac
Copy link

insmac commented Apr 19, 2019

I have GatsbyJS set up within a large monorepo with two different builds using a shared components set. The structure is as following:

src/
    /assets
        /images
    /gatsby-site
    /other-site
    /shared
gatsby-{config,node,etc.js}
package.json
...

The issue is this: I can access the shared components directory to import and use React components and logic in both GatsbyJS site and other site (native React) just fine, only that they contain images with src using a regular src=/assets/images/... tag, not ES6 imports. Obviously, they won't work in both development or built version in the Gatsby site.

What's the easiest solution to 1) make the assets directory visible to Gatsby and 2) copy these files (preferably only the used ones...) to static folder in the built version?

Best,
Maciek

@pieh pieh added the type: question or discussion Issue discussing or asking a question about Gatsby label Apr 23, 2019
@pieh
Copy link
Contributor

pieh commented Apr 23, 2019

Not ideal, but we copy files from <project-root>/static to public directory, so it would be worth checking setup when symlink is created:
<project-root>/static/assets -> <project-root>/src/assets, so those would be automatically copied.

Other option is to copy files there as part of build step - either in npm script or in gatsby-node - i.e.:

const fs = require(`fs`)
const path = require(`path`)

exports.onPostBootstrap = () => {
  fs.copySync(path.join(process.cwd(), "src", "assets", path.join(process.cwd(), `public`, "assets"))
}

(it won't watch for files and copy new one during gatsby develop tho)

@gatsbot
Copy link

gatsbot bot commented May 14, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

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

gatsbot bot commented May 25, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this as completed May 25, 2019
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. type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

2 participants