Reputation: 161
In Angular the "webpack_public_path" or "webpack_require.p" can be defined for a project in a couple of ways:
However, I need to be able to set this value at runtime so it comes from my assets/config.json file when the applicaiton starts. I'm thinking of something like the following, perhaps defined in my main.ts file, but nothing I have tried works:
__webpack_require__.p=window.config['deployUrl'];
Could someone tell me how to do this, any help would be greatly appreciated! Thanks!
Upvotes: 2
Views: 3620
Reputation: 161
After some further investigation it turns out that the answer posted for the question "In Webpack, how do I set the public path dynamically?" did work. When I originally tried this I couldn't get it working, but after trying again I was successful.
The only difference was that I did not create a globals.d.ts file to add the declare statement, I just added the following lines into my main.ts file:
declare var __webpack_public_path__:string;
__webpack_public_path__= 'public/path/location';
I'm not sure if this is best practice or not...
Upvotes: 3