-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom options can't be set with Serverless variables #103
Comments
sammort
pushed a commit
to sammort/serverless-plugin-optimize
that referenced
this issue
Oct 16, 2020
sammort
pushed a commit
to sammort/serverless-plugin-optimize
that referenced
this issue
Nov 5, 2020
fix: Evaluate custom options after hook fix Enigmatic-Smile#103
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not possible to set custom option values for the plugin with Serverless Variables. For example, we are trying to disable minification of code at local stage deployment.
The reason seems to be because the
/** Set custom options */
logic is run before any Serverless hooks. This means that the variables have not been interpolated.this.custom.optimize.minify
literally has the value specified in serverless.yml, for examplethis.custom.optimize.minify value is ${self:custom.enable_minify.${self:provider.stage}, 'true'}
I've fixed this by moving the custom options code in to the
beforeCreateDeploymentArtifacts
method, so that the options are set following thebefore:package:createDeploymentArtifacts
hook. I'm not 100% confident that is a totally safe solution but it does the job.Steps to reproduce
sls deploy -s local
Results You Received:
Code will be minified as part of optimized packaging steps.
Results You Expected:
Code is not minified as part of optimized packaging steps.
Environment Details:
Serverless: 2.1.1
serverless-plugin-optimize: 4.1.4-rc.1
The text was updated successfully, but these errors were encountered: