Hello everybody!
Today I want to show you my solution how you could make dynamic external references to JS files in SPFx Web Parts.
I’m pretty sure that you already know externals property from config.json file of your SPFx Web Parts. It is supposed to be for referencing external JS libraries from your SPFx Web Parts.
By default, the web part bundler automatically includes any library that is a dependency of the web part module. This means that the library is deployed in the same JavaScript bundle file as your web part. This is more useful for smaller libraries that are not used in multiple web parts.
But in real world you always have to create more than just one web part. So you want to have your JS libraries externally and you want to have it in your local CDN, which is for example not the same for test and production environment.
I’ve done this with modifying default GULP Tasks Definition File of SPFx Web Part.
Let’s take a look. Continue reading “Dynamic External JS References in SPFx Web Parts” →