I’m having trouble migrating from the netlify-lambda CLI to netlify-cli for lambda functions. I like the zip-it-and-ship-it model for bundling functions vs. the mysteries of webpack. Bravo for embracing this instead!
I’ve read every single support article about the included_files feature but have never once been able to get it to work. For example, I’m trying to include the file openapi.yaml:
[functions]
included_files = ["./openapi.yaml"]
Which resides next to the javascript function I’ve implemented. After running netlify functions:build --src ./myfunctions/source, I inspect the resulting zip file and there is no openapi.yaml file in it.
If in my javascript file I were to reference it like such:
require("./openapi.yaml")
which will of course cause an error because it’s a YAML file, the file is included. So how does one actually use the included_files correctly, when you have a source tree like this:
and run netlify functions:build --src netlify/functions/main, I don’t see it included in the zip file:
netlify functions:build --src netlify/functions/main
◈ Building functions
◈ Functions built to /Users/tony/dev/projects/fehguy/netlify-api/netlify/functions
OK I now understand what you meant. The file location for included_files should reference files relative to the project root (folder where netlify.toml lives), and the scripts themselves should assume that the cwd is the project root directory as well.