From d799af58da48d11afcad7f8a5df306fe6f5faee1 Mon Sep 17 00:00:00 2001 From: Anton Timmermans Date: Tue, 6 Apr 2021 15:23:53 +0200 Subject: [PATCH] Fix handling of RTL files in the manifest 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: https://github.com/romainberger/webpack-rtl-plugin/issues/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. --- src/plugins.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins.js b/src/plugins.js index 7126467..3c1bb67 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -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, } ),