# How does pattern work when packaging

**URL:** <https://forum.serverless.com/t/how-does-pattern-work-when-packaging/21347>\
**Category:** Serverless Framework\
**Created:** [August 19, 2025, 12:56am UTC](https://forum.serverless.com/t/how-does-pattern-work-when-packaging/21347 "2025-08-19T00:56:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbonner](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@mbonner](https://forum.serverless.com/u/mbonner)\
**Post date:** [August 19, 2025, 12:56am UTC](https://forum.serverless.com/t/how-does-pattern-work-when-packaging/21347/1 "2025-08-19T00:56:42Z")

</div>

Hello,

I am struggling to create a package for my app, I would think that if I specify a pattern, only files that match that pattern would be in my package, but that is not what is happening. Do I have to explicitly define what to exclude as well?

I am forced to use a very old version of serverless as well, so what I am looking for is an explanation. I have read [Serverless Framework - Packaging](https://www.serverless.com/framework/docs/providers/aws/guide/packaging) .

This is the package portion of my serverless.yml file (I have changed the names to obfuscate the actual app name)

```auto
package:  
  patterns:  
    - 'myapp/**'
    - 'second_src_dir/**'
    - '!myapp/subdir/tests.py'
    - '!myapp/subdir/test_data/**'  
  excludeDevDependencies: true

```

I have googled a fair amount and I also see examples in the format

```auto
package:  
  include:  
    - 'myapp/**'
    - 'second_src_dir/**'
  exclude:  
    - '!myapp/subdir/tests.py'
    - '!myapp/subdir/test_data/**'   
  excludeDevDependencies: true

```

but, since that format is not documented I imagine it is legacy or deprecated.

Either way, when I run serverless package the package includes everything in the repo root where serverless.yml is.

I tried adding

```auto
- '!**' 

```

as the first pattern, but when I do that the layer I am creating later errors out with

```auto
Error:
No file matches include / exclude patterns

```

I have been looking for documentation on exactly what `**` does but have not found a useful definition.

Is the syntax for include and exclude different than that for patterns?

I am also using the [Serverless Python Requirements - Serverless Framework: Plugins](https://www.serverless.com/plugins/serverless-python-requirements) plugin.

---

<div class="post-metadata">

**Author:** ![beenmeckel](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@beenmeckel](https://forum.serverless.com/u/beenmeckel)\
**Post date:** [November 5, 2025, 12:10pm UTC](https://forum.serverless.com/t/how-does-pattern-work-when-packaging/21347/2 "2025-11-05T12:10:08Z")

</div>

“some packaging” - wow that’s some design brief… seriously the amount of times have to reply and ask for a design brief - and in a design \*critiques\* sub too - it’s just painful.

[snaptube](https://snaptube.cam/)[vidmate](https://vidmate.bid/)
