I am trying to have two different style files in my react application to support both RTL and LTR directions. Therefore, I am using RTLCSS and its Webpack plugin to generate two different files: (myfile.chunk.css and myfile.chunk.rtl.css).
However, in the index.html file generated by HtmlWebpackPlugin, one of them is injected. How can I have two index files like index.html and index.rtl.html? The second file should contain RTL style files including RTL chunks.
To accomplish what you are looking for, First read the plugin documentation for:
Now, to have control over your generated HTML you need to be aware that any additional key you add to the
HtmlWebpackPluginconfig will be accessible throughhtmlWebpackPlugin.options.For example, adding
dirkey to the config:webpack.config.js
will be accessible in our template via
htmlWebpackPlugin.options.dir:index.template.html
That being said, we can switch to manual assets injection to have more control over which CSS files to include in the page, for instance
myproject.rtl.cssinstead ofmyproject.csswebpack.config.js
index.template.html
Applying the above will make it possible for you to generate
index.ltr.htmlandindex.rtl.htmlwithout hard coding bundle references.