Support webpack@^4, you should use html-webpack-plugin@next(now is html-webpack-plugin@^4.0.8).
Extend react-dev-utils/InterpolateHtmlPlugin
It works in tandem with HtmlWebpackPlugin@next.
I use it for dynamic inject library that DllPlugin generated and in React product replace '%PUBLIC_URL%'.
yarn add -D interpolate-webpack-plugin
<!-- Write any variables use %VARIABLE% -->
<!-- For example -->
<script src="%INJECT_DLL%"></script>
const InterpolateWebpackPlugin = require('interpolate-webpack-plugin');
plugins: [
// options could be an object or array.
new InterpolateWebpackPlugin([{
key: 'INJECT_DLL',
value: 'ABSOLUTELY',
type: 'STRING'
// type can only be 'STRING', 'PATH' or 'OUTPUTPATH', default is 'STRING'.
// When type is 'PATH', the 'value' you could input a glob string,like:
// process.cwd() + 'dll/*.js',
// but it could only resolve matched first file name.
}])
]
If you input wrong options or wrong type, will got a tip:
MIT License Copyright (c) 2017 TaylorPzreal