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

  - ./*.js
  - ./*
  - ./*.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

    - *.js
    - *
    - *.ts

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

  - ./h*.js
  - ./h*
  - ./h*.ts

What is the correct syntax for this?.


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:

    - 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:

    - "*.js"
    - "*"
    - "*.ts"

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