Change base href with Rspack configuration file in a Nx / React project #7985
Unanswered
iconag-bbasmer
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a hard time changing the in the head of the index.html of my React project. I'm using Nx and I just moved from Webpack to Rspack. I have tried to use the HtmlRspackPlugin but whenever I use it, I get the error message "ERROR in × Conflict: Multiple assets emit different content to the same filename index.html".
I have attached my rspack.config.js file to this message. There are a lot of other things in it but the important parts are:
const InjectBasePlugin = { apply: function (compiler) { compiler.hooks.compilation.tap('InjectContentPlugin', (compilation) => { HtmlRspackPlugin.getCompilationHooks( compilation ).afterTemplateExecution.tapPromise( 'InjectContentPlugin', async (data) => { data.html = data.html.replace( '<base href="/">', '<base href="/path/to/app/">' ); } ); }); }, };
and
config.plugins.push( new HtmlRspackPlugin({ inject: 'head', }), InjectBasePlugin );
It seems that the React build process interferes with the HtmlRspackPlugin as they both want to access and change the index.html to inject the content needed.
Any help would be much appreciated.
rspack.config.prod.js.zip
Beta Was this translation helpful? Give feedback.
All reactions