Insert script and link tags in headTags output by alterAssetTagGroups(html-webpack-plugin) into HTML through javascript code and rewrite src and href attribute with
PUBLIC_PATH
+src
orhref
.
Please define
PUBLIC_PATH
variable first in window
npm install --save-dev html-webpack-source-to-script-plugin
Require the plugin in your webpack config
import HtmlWebpackInjectScriptPlugin from 'html-webpack-source-to-script-plugin'
// or
const HtmlWebpackInjectScriptPlugin =
require('html-webpack-source-to-script-plugin').default
Add the plugin to your webpack config as follows
plugins: [new HtmlWebpackInjectScriptPlugin()]
-
externals: <HTMLTagObject>[]
: external HTMLTagObject which you want to add