8eecf0d2/netlify-local

Add Bundle command

8eecf0d2 opened this issue · 1 comments

Although this is out of the original scope for netlify-local I've been thinking a bit about the best way to implement this..

I think it's critically important to ensure end users can supply their own Webpack configurations and for netlify-local to be very cautious and explicit with any modifications it makes.

An example of the bundle command would require you to specify the Netlify and Webpack configuration files.

netlify-local bundle -n netlify.toml -w webpack.config.js

This would work in very much the same way that the serve command already does, however we need to add some logic to figure out what files are going to be used as Netlify Functions, a neat idea which I'm semi-skeptical about employing is to modify the Netlify configuration with a plugins property 🤭

Once we have a list of functions, we still need to modify the Webpack configuration - using 8eecf0d2/webpack-netlify-lambda-plugin seems like a good solution.

From there the user could define options within their Netlify configuration which will be used by 8eecf0d2/webpack-netlify-lambda-plugin.

[build]
  ...

[plugins]
  [local]
    source = "src/ts"
    functions = [
      "foo.js",
      "nested/bar.js"
    ]

I'm sorta surprised Netlify doesn't require you to specify which files are Functions but considering there's no real options for individual Functions it makes a little bit of sense.

I'd like to see Netlify support options similar to what you get with Serverless configurations (or the other way round and see Serverless support Netlify as a provider!)...

[[functions]]
  name = "foo"
  file = "functions/foo"
  method = "GET"
  ...

Modifying the schema of Netlify configuration scares me a little since they might not have thought about such a use case and even if they have it might not align with their plans for the future.

Well, I did it, added bundle command just now, enjoy.