My app is written in hugo and it is generating a json file with list of products. Products are added as markdown files, and a json file is generated on this basis.
Is there a way to copy this json file to functions folder after hugo generates a site and this json file?
So as soon as the build script is finished, postbuild runs. This is done prior to the Functions building starting.
Edit:
Of course, hugo doesn’t use a package.json and build scripts, so you could change the build command from hugo to hugo && cp path/to/file.json netlify/functions.
actually not. I forgot I had json thrown in there manually. So when I’ve changed some data in product markdown I saw that in json file in functions folder it is not updated.
Unfortunately it also doesn’t work when I switched it from netlify.toml to package.json
{
"name": "proatkiv",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "hugo",
"test": "echo \"Error: no test specified\" && exit 1",
"postbuild": "cp -f public/products/index.json netlify/functions && cd functions && npm i && cd .."
},