Closed acobster closed 3 years ago
Tested, and works as expected and defined. Only thing of note is while watching it seemed to take a really long time to compile on a javascript change.
@rbhensley this seems to happen on main
too. It might be an issue that was introduced before the PR. Do any of your recently spun-up projects have this issue?
Wrote up #60 to look into this.
Testing
Switch to the branch and watch assets for changes as you normally would:
Make some changes to JS/CSS files and note that the contents of
scripts.version
andstyles.version
change, and correspond to the query string being served for the<script>
and<link>
tags for those assets. Specifically, saving a change and then undoing that change should result in the same hash.Background
This introduces a
useHash
option to the custom WebpackAssetsVersionPlugin
which is responsible for writing to theassets.version
file, or any other version file you configure. This is the file that Conifer'sSite::enqueue_script()
andSite::enqueue_style()
methods read from to do cache-busting.The new plugin option tells the plugin to write the hash of the bundled asset's content (for example, a hash of all the JS it just compiled) to the version file instead of a simple timestamp. Passing this option has the effect of busting the browser cache only when the contents of the bundle change.
This PR also separates the CSS and JS bundles out onto their own asset version "channels," i.e. they get cached (and cache-busted) independently of each other. For example, when CSS changes, the browser will only re-download the new CSS files and JS will stay cached.