Never mind, I found the solution. Here it is
extendWebpack (cfg) { cfg.plugins.push(new webpack.DefinePlugin({ API: JSON.stringify("http://api.dev.com:3949/superservice") })) }
Not sure, if this is the best solution, but it worked. Now I can reference directly the API variable in my js code.
Best posts made by imatmati
-
RE: How to inject value/variable into JS
Latest posts made by imatmati
-
RE: How to inject value/variable into JS
Hi,
Thanks, I 'll have a look at your recommendations.
And special thanks to rstoenescu for your great work. Currently, I’m trying to establish for a (big) firm that your framework would be the right one for them. Have you something like a comparison between plain vue.js and your framework with pros and cons ? -
RE: How to inject value/variable into JS
Never mind, I found the solution. Here it is
extendWebpack (cfg) { cfg.plugins.push(new webpack.DefinePlugin({ API: JSON.stringify("http://api.dev.com:3949/superservice") })) }
Not sure, if this is the best solution, but it worked. Now I can reference directly the API variable in my js code. -
How to inject value/variable into JS
Hi,
I’m looking for a way to inject a value/variable in the application in the build process according target environments. For instance, I’d like to inject the dev address of an API for a dev application, the prod address of an API for a prod application, etc.
I gathered I could use webpack to do that. But unfortunately, every example I tried failed. Is there any reference for doing that from webpack or any other means ?
Have a nice day.