Search code examples
javascriptcssvisual-studiominify

Remove unused css / js code on Release Build in Visual Studio


Is there a way to remove unused CSS / JS from the Release Build files? Similar to how you can minify files on Release Build.

Basically, when I build my Release code, I'd like to have unused CSS / JS removed, but only in the built files. I'd like it still available in my project in case I do want to use it later on. I'd like to clean up things like extra crap from bootstrap.css and such.


Solution

  • Use Webpack's Tree Shaking

    Module bundler's like Webpack do it on the fly with the cost of minor configuration effort.