Ash
Ash

Reputation: 53

Webpack issue with a python file

I have a node.js project using webpack that's being deployed to AWS Lambda. However, I also have a single python file in the project that's powering one of the Lambda functions (i ported a legacy python script over to lambda for automation purposes). In my serverless.yml, I've set the appropriate runtimes (node.js/python) for the functions.

My problem is that webpack throws errors about my python file (it's even referencing a python/handler.js file that doesnt exist - the python handler is python/handler.py).

The exact error is: ERROR in ./python/handler.py 2:0 Module parse failed: Unexpected token (2:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

I just want webpack to bundle the regular .js files, and leave the python file alone. Note that deploying the project without webpack works, and gives me lambda functions powered by javascript and python. Does anyone have any suggestions to my issue?

Upvotes: 0

Views: 611

Answers (1)

Aaron Stuyvenberg
Aaron Stuyvenberg

Reputation: 3777

Simply add **/*.py to your excludeFiles block.

custom:
  webpack:
    excludeFiles: **/*.py # Provide a glob for files to ignore

You can read more in the documentation

Side note - you may consider trying es-build instead, which is often 10x faster than webpack. You can read more here

Upvotes: 1

Related Questions