After checking out this discussion regarding setting Build Action for an entire folder in Visual Studio, I found a solution that worked for me. My webpack configuration generates hashed files in a Build folder which are then published. However, I encountered an issue where old files that were no longer being generated were still accessible on the live site. Here's what's happening:
- During each build, all existing files in the ./Build folder are removed
- The initial build creates both
index.js
andmain.js
which are published using a wildcard configuration in the .csproj file - Subsequent builds only generate
index.js
as the rest of the files are not created, but previous versions remain on the live site
This is causing a problem because media files like .js and .css, along with images and fonts, are being bundled and hashed. The accumulation of different versions of the same files can clutter the server. Do you have any suggestions on how to resolve this issue?