I want to load different plugin per “stage”, I use Rich’s approach for this for custom variables and want to take the approach for plugins (http://www.goingserverless.com/blog/using-environment-variables-with-the-serverless-framework)
This does not load “offline”. Is there a means to see what the output of the serverless.yml parser is? Other ideas?
I want do same thing as you wanted. Have you find a way to resolve your issue?
@ztmdsbt Plugins are loaded before the
serverless.yml is parsed, so you can’t have dynamic variables like this.
Can you expand on the use case for having stage-specific plugins?
My scenario is that I would like to debug TypeScript with serverless-offline and without serverless-webpack (I was having trouble with the source mapping).
So being able to disable the webpack plugin during development, would streamline the workflow
So I guess I would not need this feature if I solved the webpack issue, but debugging without webpack is faster to build too.
I see. That does make sense, and I can understand why you would want that. Unfortunately, it doesn’t really fit with how the Framework works given the plugin loading structure. Sorry about that – your best bet is just to comment out that plugin when needed.
Thanks Alex, yeah, that is what I ended up doing. Also added documentation to the repo’s README about uncommenting and commenting those plugins.
Why not always run the plugin, and then inside the plugin access the environment from the
options object? You can then conditionally run the plugin logic.
If you don’t want to define for which environment it should run within the plugin, you could also do this within
serverless.yml and then have the plugin lookup if it should run or not based on the given environment. Something like
Indicating that it would only run its logic if the stage equals