html-webpack-plugin-inner
v1.0.3
Published
fork from html-webpack-plugin, 插入innerhtml数据
Downloads
3
Maintainers
Readme
fork from html-webpack-plugin, 插入innerhtml数据
打包后不直接把资源路径插入html,而是生成window.buildAssets,方便手动控制加载资源
config 基本和 html-webpack-plugin一样
const HtmlWebpackPlugin = require('html-webpack-plugin-inner')
new HtmlWebpackPlugin({
filename: '../index.html',
template: 'index.html',
inject: true,
assetsKey:'buildAssets' //默认
}),
打包后的代码
<script>
window.buildAssets = [{
tagName: 'link',
selfClosingTag: false,
hash: 'e9dabf34b89953a3e8c7',
attributes: {
href: '/team/client/static/css/app.css',
rel: 'stylesheet',
},
position: 'head',
},
{
tagName: 'script',
hash: 'e9dabf34b89953a3e8c7',
attributes: {
type: 'text/javascript',
src: '/team/client/static/js/app.js',
},
position: 'body',
},
]
</script>