How to add versioning filehash to dynamically required files?
See original GitHub issue- Laravel Mix Version: 1.3.1
- Node Version (
node -v
): 7.4.0 - NPM Version (
npm -v
): 5.3.0 - OS: Ubuntu 16.04
Description:
I am dynamically requiring files like so:
import(`resources/assets/images/svg/${this.name}.svg`).then((module) => {
this.svg = module;
}).catch(error => 'An error occured while loading the svg');
These chunks are outputed to an svg
directory through Webpack with the chunkFilename
property:
chunkFilename: 'js/svg/[name].js'
They get properly written to my mix-manifest.json
file with a query string containing a hash but is there any way to use this hash as well when creating dynamic imports? The dynamic imports functionality from webpack automatically injects your script based on a promise.
This would have to mean I would have to hook into the script that gets injected and add the query hash there somehow.
Any tips on how to get this done?
If this is not possible it would be a pretty big downer since it would mean images cannot be cachebusted when dynamically requiring them. In other words code splitting for assets can not be versioned.
Steps To Reproduce:
Use a dynamic require and enable .version()
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Set chunk file name that include chunkhash as below in webpack.mix.js file
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.