If you are using webpack, in your local webpack configuration you can create the file using the create-file-webpack plugin (npmjs.com/package/create-file-webpack)
Then your plugin configuration would look something like this:
plugins: [
new CreateFilePlugin({
path: `your public folder`,
fileName: 'runtime-config.js',
content: `window.runConfig=${JSON.stringify(
{
apiUrl: 'test.com/api'
}
)};`,
}),
]
And if you wanted to load your config from a file you can import it like:
Is there any way, to use this same configuration for local setup? This worked for runtime but localhost could not find them!
Hey,
If you are using webpack, in your local webpack configuration you can create the file using the create-file-webpack plugin (npmjs.com/package/create-file-webpack)
Then your plugin configuration would look something like this:
And if you wanted to load your config from a file you can import it like:
and replace
{ apiUrl: 'test.com/api'}
withmyConfigVar