Looking to dive into webpack for the first time. I am interested in exporting a global function, akin to how variables are exported using webpack.EnvironmentPlugin, in order to utilize it in typescript.
Experimented with the code snippet below just to understand its behavior:
module.exports = [{
...
...
plugins: [
new webpack.EnvironmentPlugin({
env_func: function bindObj() {
console.log("In plugin");
}
})
]
}]
However, upon trying to access it as
envFunc = process.env.env_func; envFunc.bindObj()
, I encountered the following error:
TypeError: Cannot read property 'bindObj' of undefined
Is there a method or specific plugin (similar to EnvironmentPlugin) available in webpack configuration for exporting a function that can be utilized from typescript?