What's the solution for cache busting on Symfony 6 bundle assets?

33 views Asked by At

I have a Symfony 6.4 application that uses a few custom bundles, some of which include JavaScript files. The source files are in src/MyBundle/Resources/public/js/. I use the assets:install command to compile them into the public/bundles/ folder. My issue is that when I make changes to these JS files, then run assets:install again, the filenames don't change and so user browsers tend to keep using cached files.

How can I bust the cache on bundle assets? I already use Webpack to generate file hashes for my application assets, but I can't get it to work efficiently on files in my bundles.

The best solution I can come up with right now is to write an addEntry line to my webpack.config.js file for every file in my bundles. But I have a lot of files, and don't want to add 300 addEntry lines to my config file. Is there a way to add an entire folder instead of specifying each file individually?

0

There are 0 answers