Simple way to deploy any asset with your SPFx Application

Sometimes we need to include some assets with our SPFx Application (web part or application customizer), like images, JSON files, or another stuff. By default this assets aren’t recognised by SPFx in build chain process.

For example we have some images that are in a folder that I called “assets” and I want that will be deployed with my SPFx Application because we use them in our SPFx application.

To include this assets in our SPFx package we need to create a file called “copy-static-assets.json” in the config folder and in the extensions property that is an array add an entry for each file extension that you want be deployed.

When we execute gulp bundle we can see in the log messages the indication that our assets was include, checking the messages :

After our assets will be include in our SPFx Aplication.

Thanks for reading!

%d bloggers gostam disto: