Taken from react-dev-utils, but is published as a standalone plugin and has Typescript definition.
Install using
npm install @k88/interpolate-html-plugin
This is an extension to html-webpack-plugin, so you also need to install the dependenc.
You can use %VARIABLE_NAME%
within your template HTML file and then use this plugin to replace them:
module.exports = {
...webpackConfig,
plugins: [
new InterpolateHtmlPlugin({
'NODE_ENV': 'development',
'VARIABLE_NAME': 'some-variable-value',
}),
],
}