Skip to content

IveChen/html-webpack-inject-snippet-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

安装使用

    npm install html-webpack-inject-snippet-plugin --save-dev
let HtmlWebpackInjectSnippetPlugin = require('html-webpack-inject-snippet-plugin')

...

{
    plugins:[
        new HtmlWebpackInjectSnippetPlugin({
            snippets:[
                { 
                    //required 要匹配的标签名
                    tag:tagName, 
                    //optional, true for openTag or false for closeTag.
                    //default openTag
                    isOpenTag:true, 
                    //optional, true for all and false for the first match
                    //default: just first tag
                    global: false, 
                    /**
                    * matchTagContent and snippet
                    * action = 'append'   matchTagContent + snippet
                    * action = 'prepend'  snippent + matchTagContent
                    * default ''
                    * if action not set,
                    * when isOpenTag is true, default value is 'append'
                    * when isOpenTag is false, default Value is 'prepend'
                    **/
                    action:'', //optional. 
                    snippet:'',//required the inject snippet code
                },
                //*for example
                // source code '<head>test</head>
                
                //result: <head>headInjecttest</head>
                {
                    tag:'head',
                    snippet:'headInject'
                },
                
                //result: <head>testheadInject</head>
                {
                    tag:'head',
                    isOpenTag:false
                    snippet:'headInject
                },
                //result:headInject<head>test</test>
                {   
                    tag:'head',
                    snippet:'headInject',
                    action:'prepend'
                },
                //result:<head>test</test>headInject
                {
                    tag:'head',
                    isOpenTag:false
                    snippet:'headInject',
                    action:'append'
                }
            ]    
        })
    ]
}

About

a snippet inject plugin for html-webpack-plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published