feature: pass serverless instance to plugins config
bauer01 opened this issue ยท 3 comments
bauer01 commented
Hi,
it would be nice to pass the whole serverless instance as we need to configure esbuild plugins according to our serverless settings.
Something like this maybe?
custom:
esbuild:
plugins: plugins.js
and
const getSecretConfigEnvs = (slsw) => {
const { custom } = slsw.lib.serverless.service
const secretConfigEnvs =
custom && custom.secretConfigEnvs ? custom.secretConfigEnvs : {}
return {
'process.env.__SECRETS__': JSON.stringify(secretConfigEnvs)
}
}
module.exports = (serverless) => {
const definePlugin = {
name: 'auto-node-env',
setup(build) {
const options = build.initialOptions
options.define = options.define || {}
options.define = {
...options.define,
...getSecretConfigEnvs(serverless)
}
}
}
return [
definePlugin
]
}
What do you think?
floydspace commented
Hi @bauer01, thank you for the feature request, yes it does make sense on certain occasions. so I implemented it.
Could you please check it in version 1.17.0
And apologize for the slow response.
floydspace commented
๐ This issue has been resolved in version 1.17.0 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐
bauer01 commented
Thank you so much! @floydspace ๐