html-webpack-plugin-inner

1.0.3 • Public • Published

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>

其他

Package Sidebar

Install

npm i html-webpack-plugin-inner

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

36 kB

Total Files

8

Last publish

Collaborators

  • izi