You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the emulator doesn't seem to be able to work with the serverless-webpack plugin when using sls run.
Even though everything is setup in my serverless.yml file, it doesn't seem to compile it with webpack before loading the functions.
For the time being, I found the following workaround:
Have 2 versions of your yml files (i.e. serverless.yml & serverless-webpack.yml)
Update the serverless-webpack.yml handlers to load the functions from dist/{functionName}/{functionName}.{handlerName}
Run serverless webpack --out dist from the service.
Swap the yml files name (so that the serverless.yml is now the one loading from the dist directory)
Run sls run as usual, but this time it will load the functions from the precompiled webpack dist directory.
I created some helper scripts in my package.json to make this process a little easier:
Please note that if you want to use those scripts, the serverless.yml file must be the one loading the handlers from the dist directory prior to running npm run-script sls-webpack-run, since it will switch back the files before compiling with webpack and it switches them back when it's done. This is to ensure that every time we run sls-run, we load the functions from the dist directory, even if we didn't re-compile it with webpack beforehand.
But it'd be great if there was a way to use the serverless-webpack plugin with sls-run out-of-the-box!
The text was updated successfully, but these errors were encountered:
vincentsolutions
changed the title
Add webpack support for emulator and event-gateway
Add serverless-webpack support
Oct 29, 2017
Currently, the emulator doesn't seem to be able to work with the
serverless-webpack
plugin when usingsls run
.Even though everything is setup in my
serverless.yml
file, it doesn't seem to compile it with webpack before loading the functions.For the time being, I found the following workaround:
yml
files (i.e.serverless.yml
&serverless-webpack.yml
)serverless-webpack.yml
handlers to load the functions fromdist/{functionName}/{functionName}.{handlerName}
serverless webpack --out dist
from the service.yml
files name (so that theserverless.yml
is now the one loading from thedist
directory)sls run
as usual, but this time it will load the functions from the precompiled webpackdist
directory.I created some helper scripts in my
package.json
to make this process a little easier:Please note that if you want to use those scripts, the
serverless.yml
file must be the one loading the handlers from thedist
directory prior to runningnpm run-script sls-webpack-run
, since it will switch back the files before compiling with webpack and it switches them back when it's done. This is to ensure that every time we runsls-run
, we load the functions from thedist
directory, even if we didn't re-compile it with webpack beforehand.But it'd be great if there was a way to use the
serverless-webpack
plugin withsls-run
out-of-the-box!The text was updated successfully, but these errors were encountered: