I'm writing a Webpack plugin that, besides its main purpose, needs to add some global variables to the build. Normally, I would use definePlugin
for declaring global variables, but I can't seem to easily replicate its behaviour inside my plugin. Is there any way to call definePlugin
from inside of my plugin, or is there another way to declare global variables inside of a Webpack plugin?
I realise I can just copy the entirety of the definePlugin
code, but I feel like there has to be a cleaner and more future-proof solution?
I could also pass a --env=…
argument when running webpack, but this would require me to edit the command manually each time, and I'm not even sure I could reach it in the plugin that way.