# Syntax for excluding files with wildcard?

**URL:** <https://forum.serverless.com/t/syntax-for-excluding-files-with-wildcard/1157>\
**Category:** Serverless Framework\
**Created:** [January 21, 2017, 3:55pm UTC](https://forum.serverless.com/t/syntax-for-excluding-files-with-wildcard/1157 "2017-01-21T15:55:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkristia](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@jkristia](https://forum.serverless.com/u/jkristia)\
**Post date:** [January 21, 2017, 3:55pm UTC](https://forum.serverless.com/t/syntax-for-excluding-files-with-wildcard/1157/1 "2017-01-21T15:55:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [January 23, 2017, 4:02am UTC](https://forum.serverless.com/t/syntax-for-excluding-files-with-wildcard/1157/2 "2017-01-23T04:02:11Z")

</div>

Hey Jesper

> [@jkristia](#):
>
> seems like the handler file must be at the same location as the yml file

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

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

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

```

---

<div class="post-metadata">

**Author:** ![jkristia](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@jkristia](https://forum.serverless.com/u/jkristia)\
**Post date:** [January 23, 2017, 4:20am UTC](https://forum.serverless.com/t/syntax-for-excluding-files-with-wildcard/1157/3 "2017-01-23T04:20:08Z")

</div>

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