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

Question: How to access copyed files during postBuild when in develop mode #1208

Closed
jairmilanes opened this issue Jun 19, 2017 · 4 comments
Closed
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@jairmilanes
Copy link

So I used the postBuild on the gatsby-node.js file to copy a few static scripts to the public/assets/ folder on every build, they are all js scripts that don´t need to be processed by webpack like jquery and a few plugins.

There are no code related to this files inside my pages, they are only used by one of the script files that also get´s moved during the postBuild.

I can access this files using serve-build but not on develop, they all return 404 when I put them on script tags like <script src="assets/js/jquery-2.1.3.min.js"></script>

Is there a way I can properly access this files during develop mode?

@jairmilanes jairmilanes changed the title How to access copyed files during postBuild when in develop mode Question: How to access copyed files during postBuild when in develop mode Jun 19, 2017
@KyleAMathews
Copy link
Contributor

Which version of Gatsby are you on?

If you copy the files manually to the public directory do things work in development?

@jairmilanes
Copy link
Author

I´m using 0.12.48, it does not work even if I copy them manually.

The thing here is that when in develop the server looks for files inside the /pages directory and not in public or in the root directory.

So just to be clear on what I´m trying to acomplish here, I have this pure HTML template that I´m building my site from, I´m trying to convert this template to a React app, but some features on this template uses jQuery and a few plugins.

So using postBuild I copy the existing .js files from assets/js to inside the public/assets/js and use script tags to add them to the html.js file.

When I build my website the files are moved and I can serve-build and everything loads fine, but when on develop the server looks for this files inside the /pages folder, and surely does not find any asset, so it returns 404 for all of them and the site breaks.

So is there a way to while on develop, load point this static assets either to the root/* or the public/* instead of looking into pages only?

@KyleAMathews
Copy link
Contributor

You might want to try doing this a more Gatsby/webpack native way https://stackoverflow.com/questions/28969861/managing-jquery-plugin-dependency-in-webpack

I'm not sure why the develop server isn't loading your files though they should.

@stale
Copy link

stale bot commented Dec 16, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

2 participants