diff --git a/lib/webpack-manifest-plugin/hooks.js b/lib/webpack-manifest-plugin/hooks.js index c1a32e63..817bedf1 100644 --- a/lib/webpack-manifest-plugin/hooks.js +++ b/lib/webpack-manifest-plugin/hooks.js @@ -119,14 +119,16 @@ const normalModuleLoaderHook = ({ moduleAssets, assetTypeModuleAssets }, loaderC // the "emitFile" callback is never called on asset modules // so, we create a different map that can be used later in the "emit" hook if (['asset', 'asset/inline', 'asset/resource', 'asset/source'].includes(module.type)) { - Object.assign(assetTypeModuleAssets, { // This takes the userRequest (which is an absolute path) and turns it into // a relative path to the root context. This is done so that the string // will match asset.info.sourceFilename in the emit hook. - [relative(loaderContext.rootContext, module.userRequest)]: basename( - module.userRequest - ) - }); + let sourceFilename = relative(loaderContext.rootContext, module.userRequest); + // at this point, Windows paths use \ in their paths + // but in the emit hook, asset.info.sourceFilename fill have UNIX slashes + sourceFilename = sourceFilename.replace(/\\/g, '/'); + Object.assign(assetTypeModuleAssets, { + [sourceFilename]: basename(module.userRequest), + }); } // eslint-disable-next-line no-param-reassign