|--serverless.yml
|--lib/
|--node_modules/
|--api/
|--manageclient/
|--addClient/
|--handler.js
This is my folder structure , how to deploy function using serverless so that it includes only handler.js and node_modules/ and lib/.
Can you please specify the function command to be written on main serverless.yml?
My YML function statement
handler: api/manageclient/addClient/addclient.addclient
package:
exclude:
- ./*
- !api/manageclient/addClient/**
- !api/node_modules/**
- !api/lib/**
This is my structure:
package:
individually: true
exclude:
- ./**
and in my function:
functions:
lambda:
handler: dist/index.handler
package:
include:
- 'dist/**/*'
- '!dist/**/*.map'
- '!node_modules/aws-sdk/**/*'
First you tell serverless you want to exlude everything and you say that each function will include their own files.
Inside each function I include everything inside a specific folder (as dist
) and then to exclude specific files as files ending with .map
or, for example, the aws-sdk
library inside node modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With