# Exclude everything in the build except one folder Serverless Patterns

**URL:** <https://forum.serverless.com/t/exclude-everything-in-the-build-except-one-folder-serverless-patterns/16693>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [February 10, 2022, 3:39pm UTC](https://forum.serverless.com/t/exclude-everything-in-the-build-except-one-folder-serverless-patterns/16693 "2022-02-10T15:39:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohail](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rohail/32/6573_2.png) [@rohail](https://forum.serverless.com/u/rohail)\
**Post date:** [February 10, 2022, 3:39pm UTC](https://forum.serverless.com/t/exclude-everything-in-the-build-except-one-folder-serverless-patterns/16693/1 "2022-02-10T15:39:32Z")

</div>

I am working on a serverless project. what I want to achieve or want to know if it is possible or not is that when I run` sls package` i want the serverless to exclude every file/folder in the root directory except for one folder.

I have tried multiple ways to do it using patterns in serverless file but nothing worked.

```auto
package: #This didn't not work
  patterns:
    - '!./**'
    - './dist/**'

package: # This didn't work
  patterns:
    - '!.*/**'
    - './dist/**'

```

Am I missing something? Because I was able to exclude particular folders if I define them explicitly. But I was unable to exclude the entire root directory using wild card characters.

```auto
package: # This works and excludes constant folder
  patterns:
    - '!./constants/**'

```

I know I can achieve it by making a script. But I want to know if it can be done via the serverless framework by simply defining the patterns.
