Using gulp with serverless

Has anyone created a project to prepare their project to a build folder before serverless packages the service for deployment?

I see that serverless seems to package every module in node_modules, even if they are saved for development purposes only. As I am creating my servicing using some npm modules for development purposes, seems like a waste to package them up when they aren’t needed.

The problem is it’s hard for Serverless to know which modules are used for your application, and which are only used for development - NPM v3 tries to store them as flat as possible, so it’s not simple.

I have gotten around this by installing my function dependencies in subdirectories, and then packaging up the them. I put my development dependencies in the top level of my service, and ignore it for packaging purposes.

The only issue is that I have to have a package.json in each function directory, but I actually like this as it makes dependencies explicit per function.

I thought of doing something similar where I would have build folders for local development/testing vs build/deploy folders. The only problem with that is keeping the dependencies in sync between the two folders to ensure I don’t miss anything. Unit Testing should hopefully find anything missing but that is assuming tests have 100% code coverage - that would be Utopia.

I maintain excludes in serverless.yml for all dev dependencies and everything else don’t need in runtime, like the .git folder