Syntax for excluding files with wildcard?

I’m using webpack to create a single bundle.js in my service src folder (seems like the handler file must be at the same location as the yml file).
Now I would like to exclude all other files from the zip. I have tried this, but it still includes the files

  exclude:
  - ./*.js
  - ./*.js.map
  - ./*.ts

I have tried several other combinations, but can’t get neither to work. Either it doesn’t exclude the files or I get a yml syntax error (using yaml validation in VS Code) like when trying this

  exclude:
    - *.js
    - *.js.map
    - *.ts

Only if I specify the filename like this does it exclude all ‘h…’ files

  exclude:
  - ./h*.js
  - ./h*.js.map
  - ./h*.ts

What is the correct syntax for this?.

Thanks
Jesper

Hey Jesper

Not true. My serverless.yml is in the root folder. I then use src for my TypeScript source and dist for the output from the TypeScript compiler. My serverless.yml then sets the handler as dist/cards/cards.handler (for example).

I exclude the src folder and @types by using the following in my serverless.yml:

package:
  exclude:
    - node_modules/@types/**
    - src/**
    - tsconfig.json
    - tslint.json
    - .npmignore
    - .vscode/**
    - "**/.gitkeep"

I think you can fix your syntax errors by enclosing the patterns that start with a * in quotes:

  exclude:
    - "*.js"
    - "*.js.map"
    - "*.ts"

Thank your help, I will give this a try.
Edit: yep, wrapping the pattern in quotes fixes the syntax error.