Copy files to build folder before plugin runs

My SSG does not copy over some directories I need in my build folder. Hopefully I can copy these folders before the build triggers plugins because I’m trying to get my site working before setting up Algolia search which runs after building.

Here is my build command, where would I add 2 folders to copy? I’m not working in Linux so I’m asking. I’m famous for syntax errors!

chmod +x ./command && ./command build

The answer kind of depends on the plugins you are using - there are many different points in a build where they could run.

However, if you just need to do it as part of your build command, you could add the copying to the ./command script. You could also do wget -r && chmod +x ./command && ./command build or something to pull them down outside the script.

If you need it to run before a plugin could run at all, you’d need ironically need to write a plugin to do it (since otherwise there is no way for you to run something before an early plugin) - you’d want one that hooks into the “onPreBuild” stage described here: Create Build Plugins | Netlify Docs

The plugin I want to use is algolia search crawler. All I know is that it won’t work using drag/drop manual uploading, it needs the build trigger to run but where in the build it runs is unknown to me. Do you happen to know?

That wget command looks interesting. Does that upload to the Netlify build folder?

Since it needs to “crawl” your built site, that one should run at the end of the build. So, you should be ok to just add the copy commands to your build script.

Please show the copy command to do this. I know it starts with “cp” but how to show the folders syntax is what I need. I need to copy 2 folders from my git repo. Let’s say folder1 and folder2. What would the syntax be?

OK, I used this and it seems to work → cp -r ./folder1/ ./build