inner script webpack plugin
Basic
const HtmlWebpackPlugin = const WebpackPluginInnerScript = ; moduleexports = entry: './index.js' output: path: __dirname + '/dist' filename: 'index_bundle.js' plugins: normal<script type="text/javascript" src="index_bundle.js"></script> now<script type="text/javascript">var oHead = document oScript = document;oScripttype = "text/javascript";oScriptsrc = "index_bundle.js";oHead;</script>
Params
innerScript <true | false> default: true
Used to set introversion
include <RegExp | ""> default: ''
Used to set match src of script
attr
Used to set the attributes of the script
like:
attr: {
defer: "defer"
}
Example
Only set attributes
const HtmlWebpackPlugin = const WebpackPluginInnerScript = ; moduleexports = entry: './index.js' output: path: __dirname + '/dist' filename: 'index_bundle.js' plugins: innerScript: false attr: async: "async" normal<script type="text/javascript" src="index_bundle.js"></script> now<script type="text/javascript" src="index_bundle.js" async="async"></script>
Both set attributes and innerScript
const HtmlWebpackPlugin = const WebpackPluginInnerScript = ; moduleexports = entry: './index.js' output: path: __dirname + '/dist' filename: 'index_bundle.js' plugins: innerScript: true attr: async: "async" normal<script type="text/javascript" src="index_bundle.js"></script> now<script type="text/javascript">var oBody = documentoScript = document;oScripttype = "text/javascript";oScriptsrc = "index_bundle.js";oScriptasync = "async";oBody;</script>
let the file containing the 'index'
plugins: innerScript: true include: /index/ attr: async: "async" normal<script type="text/javascript" src="index_bundle.js"></script><script type="text/javascript" src="cc_bundle.js"></script> now<script type="text/javascript">var oBody = documentoScript = document;oScripttype = "text/javascript";oScriptsrc = "index_bundle.js";oScriptasync = "async";oBody;</script><script type="text/javascript" src="cc_bundle.js"></script>