Serve the full website
niicojs opened this issue · 5 comments
I think it would be better to:
- server the full website (easier to test lambda functions in context)
- server the function with the
/.netlify/functions/
path) - parse .env to set environment variables
I did it here for personal use, I can PR it if it make sense for others.
@niicojs It makes sense for me. I'll use your fork unless/until there is an alternative.
There are many different ways people serve their app depending on the framework, setup, etc. etc. etc.
I'd suggest an approach like this https://github.com/netlify/netlify-faunadb-example/blob/master/package.json#L15-L17
Where you can use npm-run-all
to run the function code + your web app in the same terminal session.
If you clone down that repo, npm install
, and npm start
you can see it in action
Thanks for the suggestion @DavidWells. In my specific case I'm not using react or webpack and don't want those additional dependencies just to proxy requests. I'm using browsersync for serving static files and can proxy netlify-lambda functions locally, but without native rewrite support. This makes niicojs' idea/fork useful to me.
@sparkalow if you're still looking for alternatives, I've written 8eecf0d2/netlify-local to support more Netlify services locally, namely the static file server for the publish
directory of netlify.toml
configs. Webpack is included as a dependency but usage is completely optional.