用于为webpack生成的html文件添加自定义属性
npm install html-add-attr-webpack-plugin -D Example
for SPA (single-page-application):
//webpack.config.js module.exports = { plugin: [ //...other options new HtmlAddAttrWebpackPlugin({ attrs: { 'script': { crossOrigin: 'anonymous' } } }) ] }//will add crossOrigin="anonymous" to script tag.
for multi-page application:
//webpack.config.js module.exports = { plugin: [ //...other options new HtmlAddAttrWebpackPlugin([{ attrs: { 'script': { crossOrigin: 'anonymous' } } //will rewrite index.html }, { sourceFile: 'sub.html', attrs: { 'link': { class: 'link' }, 'script': { class: 'sub' } } //will rewrite sub.html }]) ] } Options option
props | description |
---|---|
sourceFile | the html file that needs to rewrite. (default 'index.html') |
attrs | attributes need to add |
props | description |
---|---|
key | css-selector 'script' means script tags |
value | attribute's key-value |
tks for using
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。