Skip to content

Commit

Permalink
symfony#936: Ensure sourceFilename is set in asset info when a file i…
Browse files Browse the repository at this point in the history
…s emitted
  • Loading branch information
bobvandevijver committed May 18, 2021
1 parent 972c882 commit af2d023
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/webpack-manifest-plugin/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,18 @@ const emitHook = function emit(
const normalModuleLoaderHook = ({ moduleAssets }, loaderContext, module) => {
const { emitFile } = loaderContext;

// assetInfo parameter was added in Webpack 4.40.0
// eslint-disable-next-line no-param-reassign
loaderContext.emitFile = (file, content, sourceMap) => {
loaderContext.emitFile = (file, content, sourceMap, assetInfo) => {
const info = Object.assign({}, assetInfo);

if (module.userRequest && !moduleAssets[file]) {
Object.assign(moduleAssets, { [file]: join(dirname(file), basename(module.userRequest)) });
info.sourceFilename = join(dirname(file), basename(module.userRequest));

Object.assign(moduleAssets, { [file]: info.sourceFilename });
}

return emitFile.call(module, file, content, sourceMap);
return emitFile.call(module, file, content, sourceMap, info);
};
};

Expand Down

0 comments on commit af2d023

Please sign in to comment.