I'm currently working with Webpack and Angular, trying to find a way to inject/use variables based on whether it's in development or production mode.
Although I have Webpack set up to detect the environment (prod or dev), I am facing an issue with passing variables to JavaScript / Angular.
Initially, I thought using DefinePlugin would be the solution, but unfortunately, it is not recognized as a global variable in JavaScript / Angular.
new webpack.DefinePlugin({
API_URL: JSON.stringify('testing')
}),
Does anyone have a workaround for this issue? I really need to pass variables or files to Angular depending on whether it's in production or development. For example, the base URL of the backend API may differ between the two environments.
Manually commenting out lines seems like a cumbersome approach if there is a more automated solution available.
As mentioned earlier, I am able to differentiate between production and development modes in Webpack, but struggling to communicate this information to Angular / JavaScript. Any suggestions?