As I develop my static site using HTML files served from a simple web server, I want to use local, non-minified versions of Javascript code and CSS files. However, when it comes time to deploy the site, I would like to refer to minified versions of these same files.
To achieve this, my current approach involves adding data-prod-href
and data-prod-src
attributes to script
and link
tags. This allows me to replace the references during the build process. While this method ensures valid HTML and enables me to develop without constantly running the build script, I can't help but feel that it might be reinventing the wheel.
After searching extensively, I have not come across any established best practices for handling this scenario. Is there something obvious that I am overlooking?