a plugin for html-webpack-plugin,which can inject static file content into html page
npm install content-inject-pluginjavascript
var ContentInjectPlugin = require('./plugins/contentInjectPlugin');
new ContentInjectPlugin({
contents:{
content: 'this is inject content',
rem: function(){
return fs.readFileSync('./src/static/js/rem.js',{encoding:'utf8'});
},
other: 'other file content'
},
replaceMode: 'all',
memo: true
})
`
in template
`html
template
{{{__other__}}}
`
Params
Parameter | Type | Default | Options | Description
--------- | ---- | ------| ----- |---------------
contents | array | | | the content's array, which key used by tag in template, like {{{__key__}}}, support function to get content
replaceMode | string | all | all,first | replace all matches or the first match
memo | boolean` | | | memorize the content or not