Skip to content
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

feature: pass serverless instance to plugins config #168

Closed
bauer01 opened this issue Aug 3, 2021 · 3 comments
Closed

feature: pass serverless instance to plugins config #168

bauer01 opened this issue Aug 3, 2021 · 3 comments
Labels

Comments

@bauer01
Copy link

bauer01 commented Aug 3, 2021

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 added a commit that referenced this issue Sep 4, 2021
@floydspace
Copy link
Owner

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
Copy link
Owner

🎉 This issue has been resolved in version 1.17.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bauer01
Copy link
Author

bauer01 commented Sep 23, 2021

Thank you so much! @floydspace 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants