Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork200
Open
Description
Let's improve on this PR to be able to use CopyWebpackPlugin AND add hashes to the destination files when needed:#409
For reference on how we could accomplish this, the ManifestPlugin can be used to produce hashed files for the CopyWebpackPlugin when needed (code from my personal website):
returnnewManifestPlugin({filter(fileDescriptor){// Filter out some weirdness coming from source scss filesreturn!fileDescriptor.name.match(/.scss$/);},map(fileDescriptor){// Correct entries regarding the copy-webpack-plugin// adding hashes to both handle and file nameconstcopyReplacePattern=newRegExp(`(${config.serverPath}/images/backgrounds)/(.+)-([0-9a-f]{8}).(jpg)`,);constcopyMatches=fileDescriptor.name.match(copyReplacePattern);if(copyMatches&©Matches.length===5){fileDescriptor.name=`${config.serverPath}/images/backgrounds/${copyMatches[2]}.${copyMatches[4]}`;}returnfileDescriptor;},writeToFileEmit:true,basePath:`${config.serverPath}/`,publicPath:config.isHmr ?`//${config.serverHost}:${config.serverPort}/${config.serverPath}/` :`/${config.serverPath}/`,});
This functionknows in advance that the only copied files are some images I had in a specific directory, but we can adapt this logic to fix hashes going into the manifest in a more general way.
With this, we could probably stop using the forked WebpackManifestPlugin, as@weaverryan said:
but I think maybe we don’t need that anymore, as the PR I linked to IS merged nowSo we could probably require the plugin again at version 3.1.1 or higher
... and work our way from there.
So, to summarize, from@weaverryan :
So, things we could do:
- Re-add WebpackManifestPlugin properly (instead of using a copy)
- Investigate getting CopyWebpackPlugin working with WebpackManifestPlugin (found this[Feature] Support manifest file webpack-contrib/copy-webpack-plugin#104 (comment) )
- If we do (A) and (B), we could deprecate our custom copy() functionality, which is pretty complex
Metadata
Metadata
Assignees
Labels
No labels