# How can the test directory be excluded from webpack packaging?

**URL:** <https://forum.serverless.com/t/how-can-the-test-directory-be-excluded-from-webpack-packaging/2578>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [August 25, 2017, 5:58pm UTC](https://forum.serverless.com/t/how-can-the-test-directory-be-excluded-from-webpack-packaging/2578 "2017-08-25T17:58:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramanbuttar](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@ramanbuttar](https://forum.serverless.com/u/ramanbuttar)\
**Post date:** [August 25, 2017, 5:58pm UTC](https://forum.serverless.com/t/how-can-the-test-directory-be-excluded-from-webpack-packaging/2578/1 "2017-08-25T17:58:44Z")

</div>

Right now, my test directory code is getting included in the webpack package built and uploaded to AWS Lambda. How can I exclude this directory? I tried different things from [https://webpack.github.io/docs/configuration.html](https://webpack.github.io/docs/configuration.html) but none have helped so far.

---

<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:** [August 29, 2017, 11:07am UTC](https://forum.serverless.com/t/how-can-the-test-directory-be-excluded-from-webpack-packaging/2578/2 "2017-08-29T11:07:48Z")

</div>

By default webpack should have tree shaking enabled which would exclude the test files unless you’re including them some how. Are you able to share your webpack config and the location of your test folder?

---

<div class="post-metadata">

**Author:** ![ramanbuttar](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@ramanbuttar](https://forum.serverless.com/u/ramanbuttar)\
**Post date:** [September 6, 2017, 5:15pm UTC](https://forum.serverless.com/t/how-can-the-test-directory-be-excluded-from-webpack-packaging/2578/3 "2017-09-06T17:15:50Z")

</div>

**webpack.config.js**

```
const nodeExternals = require('webpack-node-externals');
const webpack = require('webpack');
const path = require('path');

module.exports = {
  entry: './handler.js',
  target: 'node',
  externals: [nodeExternals()],
  plugins: [
    new webpack.IgnorePlugin(/\.(md|yml.encrypted|sh|vm)$/)
  ],
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: "babel-loader"
      },
      { 
        test: /\.json$/,
        loader: "json-loader"
      },
      {
        test: /\.yml$/,
        loader: "yml"
      }
    ]
  }
};

```

I’d like to exclude `node_modules`, `test`, `scripts`, `bin` directories.
