floydspace / serverless-esbuild

💨 A Serverless framework plugin to bundle JavaScript and TypeScript with extremely fast esbuild

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature: pass serverless instance to plugins config

bauer01 opened this issue · comments

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?

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.

:tada: This issue has been resolved in version 1.17.0 :tada:

The release is available on:

Your semantic-release bot 📦🚀

Thank you so much! @floydspace 👍