How can the test directory be excluded from webpack packaging?
ramanbuttar opened this issue · 4 comments
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 but none have helped so far.
@ramanbuttar If I am understanding your issue correctly, it is actually tackled in your core serverless config. See this documentation.
package:
exclude:
- node_modules/**
- your_test_directory/**
@brianjd I tried the above but my expect
statements from test/
directory are still being included in my webpack'd and zipped handler.js
file. I don't need to have that code in AWS Lambda.
@ramanbuttar please check the webpack.config from e.g. https://github.com/SC5/sc5-serverless-boilerplate/blob/master/webpack.config.js
@ramanbuttar @mpuittinen Approach looks solid, it dynamically generates entry points for each function using the serverless config. Therefore avoiding the tests being bundled, especially if you previously had broad directory inclusion / entry points.