Skip to content

Commit

Permalink
Fix handling of RTL files in the manifest
Browse files Browse the repository at this point in the history
When using the WebpackRTLPlugin the manifest doesn't produce entries
for both the original and the RTL file. This results in the wrong file
being loaded. This is caused by the fact that both files are in the
same chunk.

There is an issue tracking this on the WebpackRTLPlugin:
romainberger/webpack-rtl-plugin#14

This commit includes a workaround. By providing a `map` function to
the manifest plugin we can change the name when we're dealing with an
RTL file. That results in two entries in the eventual manifest.
  • Loading branch information
atimmer committed Apr 6, 2021
1 parent 600a7d7 commit d799af5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ module.exports = {
manifest: ( options = {} ) => new ManifestPlugin( {
fileName: 'asset-manifest.json',
writeToFileEmit: true,
map: ( file ) => {
// Makes sure an RTL file has a separate entry in the manifest
if ( /\.rtl\.css$/.test( file.path ) ) {
file.name = file.name.replace( '.css', '.rtl.css' );
}

return file;
},
...options,
} ),

Expand Down

0 comments on commit d799af5

Please sign in to comment.