0.0.1 • Published 4 years ago

html-insert-tag-webpack-plugin v0.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

html-insert-tag-webpack-plugin

Insert tags into html

Install

  npm i html-insert-tag-webpack-plugin -D

webpack.config.js

    const HtmlWebpackPlugin = require('html-webpack-plugin'),
    HtmlInsertTagWebpackPlugin = require('html-insert-tag-webpack-plugin')
    module.exports = {
      plugins: [
        new HtmlWebpackPlugin(),
        new HtmlInsertTagWebpackPlugin([{
            tagName: 'link',
            inject: {
              tagName: 'head',
              location: 'before'
            },
            attributes: {
              href: 'http://www.example.com/css/common.css'
            }
          }, {
            tagName: 'script',
            inject: {
              tagName: 'body',
              location: 'after'  
            },
            attributes: {
              src: 'http://www.example.com/js/utils.js'
            }
          }, {
            tagName: 'div',
            inject: {
              tagName: 'body',
              location: 'scriptBefore'
            },
            attributes: {
              style: 'font-size: 18px'
            },
            innerHTML: 'html-insert-tag-webpack-plugin'
        }])
      ]
    }
    

{ Array\<object> | object } options

NameTypeDescriptionAccepted ValuesDefault
tagNamestringInserted tag name--
injectobjectInject the given tag configuration--
inject.tagNamestringInject the given tag namehead/bodyhead
inject.locationstringInjection locationafter/before/scriptBeforeafter
attributesobjectTag attributes--
innerHTMLstringThe Element property innerHTML gets or sets the HTML or XML markup contained within the element.--