I have a few goals I'd like to achieve but I'm unsure of how to get there:
- Create a single-click deployment for my web project that includes a minified javascript file
- Version my minified JavaScript file to prevent browser caching of static content whenever a new build is pushed
- Reference the versioned JavaScript file on RELEASE builds, and the non-minified version of the JavaScript files with DEBUG builds
From this article:
http://encosia.com/automatically-minify-and-combine-javascript-in-visual-studio/
I've added JSMin to minify my files using a command like this:
"$(SolutionDir)Tools\jsmin.exe" < "$(ProjectDir)Scripts\myfile.js" > "$(ProjectDir)Scripts\myfile.min.js"
I'll also be adding this to my web pages for preserving non-minified files during debug mode:
<% if (HttpContext.Current.IsDebuggingEnabled) { %>
<script type="text/javascript" src="scripts\myfile.js"></script>
<% } else { %>
<script type="text/javascript" src="scripts/myfile.min.js"></script>
<% } %>
So really I'm left with trying to figure out how to prevent myfile.min.js being seen as static content by a web browser when it is updated. If my goal wasn't single-click deployment I could just add a version number manually, but that doesn't seem like a solid approach. Thoughts?
scripts/myfile.min.js?v=1.0
It'd be best to interpolate the src string with the version number. – DianoeticAssemblyInfo
and you can get version info. But, it's apparently easier for everyone to remember to update app.config thanAssemblyInfo
. – Dianoetic