Implements #15 using assets manifests to keep this bundling ecosystem compatible with Webpack.
[x] Calculate content hash of JS and CSS files
[x] Fingerprint dependencies of CSS files and rewrite the CSS accordingly
[x] Create asset manifest with all of the above
Usage
To include fingerprints in the asset filenames, you must invoke the bundle command with the -m option. This will include a fingerprint in the filenames:
...and generate a manifest, mapping all bundles' and all their dependencies' file names to the fingerprinted versions:
This will yield <script src="/static/vendor.7b1f7cb.js"></script> in the output document.
Cleaning
When using a manifest, we keep track of all files. To ensure our output directory only contains those that are really referenced, the XP bundler will make use of this and delete any previous versions when it runs:
Implements #15 using assets manifests to keep this bundling ecosystem compatible with Webpack.
Usage
To include fingerprints in the asset filenames, you must invoke the bundle command with the
-m
option. This will include a fingerprint in the filenames:...and generate a manifest, mapping all bundles' and all their dependencies' file names to the fingerprinted versions:
Like GIT, we use the first 7 characters of an SHA1 checksum for fingerprinting.
This manifest needs to be passed to the frontend:
Now, you can access the access the real filenames of your assets in your templates, for example:
This will yield
<script src="/static/vendor.7b1f7cb.js"></script>
in the output document.Cleaning
When using a manifest, we keep track of all files. To ensure our output directory only contains those that are really referenced, the XP bundler will make use of this and delete any previous versions when it runs: