title: serverless webpack config, manually add directory
body: <p>I have the following code I am running that is failing to work because it can not find the models folder when I upload to amazon.</p>
  
  <pre><code>exports.setModels = function(connection,modelPath){
    //Import all the known models for the project.
  
    //Proof of Stage being set.
    console.log("stage for models="+stage);
  
    const fs = require('fs');
    const dir = modelPath;
  
    var models = {};
  
    //@JA - Wait until this function finishes ~ hence readdirSync vs regular readdir which is async
    fs.readdirSync(dir).forEach(file =&gt; {
      console.log("file="+file);
      //Split the .js part of the filename
      var arr = file.split(".");
      var name = arr[0].toLowerCase();
      //Create a modle object using the filename as the reference without the .js pointing to a created sequelize instance of the file.
  
      var modelPath = "../models/"+file; //default assumes same directory that was used to scan.
      if(process.env.DOMAIN_NAME){ //If this enviroment variable is detected then change the modelPath.
        modelPath = "../../../../models/"+file;
      }
      models[name] = connection.import(modelPath);
    })
    return models;
  }
  </code></pre>
  
  <p>After investigating the issue, I found out its because the models folder is not being packaged by the serverless webpack plugin.</p>
  
  <p>I found out recently how to force certain packages to upload using this code in my serverless file.</p>
  
  <pre><code>webpackIncludeModules:
      forceInclude:
        - mysql
        - mysql2
  </code></pre>
  
  <p>This will only seem to include packages however, and when I tried to reference the models folder to automatically include all my sequelize models I got an error saying it was not a package, which of course makes sense.</p>
  
  <p>This does leave me with the question of <strong>how I can get it to package the models directory without manually doing a require for each model</strong>.  I wrote a dynamic function to get them at runtime and import it to sequelize.</p>
  
  <p>Information on the plugin is here (<a href="https://github.com/serverless-heaven/serverless-webpack" rel="nofollow noreferrer">https://github.com/serverless-heaven/serverless-webpack</a>), I looked through it all but can't seem to find the answer.</p>
  
  <p>The output of packaging with serverless looks like this, missing the models folder with all my sequelize models.</p>
  
  <p><a href="https://i.stack.imgur.com/hnoRx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hnoRx.png" alt="enter image description here"></a></p>
  
  <p>My main directory before doing webpack looks like this.</p>
  
  <p><a href="https://i.stack.imgur.com/9NoFo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9NoFo.png" alt="enter image description here"></a></p>
  
  <p>Here is my webpack.config.js as well.</p>
  
  <pre><code>const slsw = require("serverless-webpack");
  const nodeExternals = require("webpack-node-externals");
  
  module.exports = {
    entry: slsw.lib.entries,
    target: "node",
    // Since 'aws-sdk' is not compatible with webpack,
    // we exclude all node dependencies
    externals: [nodeExternals()],
    // Run babel on all .js files and skip those in node_modules
    module: {
      rules: [
        {
          test: /\.js$/,
          loader: "babel-loader",
          include: __dirname,
          exclude: /node_modules/
        }
      ]
    }
  };
  </code></pre>