
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
html-webpack-inject-attributes-plugin
Advanced tools
add custom attributes to inject tags
npm install html-webpack-inject-attributes-plugin -D
please use it after
html-webpack-plugin, especially in webpack2+.
plugins = [
new HtmlWebpackPlugin(),
new htmlWebpackInjectAttributesPlugin({
inject: "true",
async: true,
test: {}
}) // Object, key should be string, value can be string or function、object, object will stringify
]
you got
<script type="text/javascript" src="index.js" inject="true" async test="{}"></script>
plugins = [
new HtmlWebpackPlugin({
attributes: {
'data-src': function (tag) { return tag.attributes.src }
},
}),
new htmlWebpackInjectAttributesPlugin()
]
/**
* if value is a function, got three arguments。
* 1、tag, ast of tag node
* 2、compilation, you can get webpack build hash by compilation.hash
* 3、index, index of trunks
**/
you got
<script type="text/javascript" src="index.js" data-src="index.js" inject="true"></script>
plugins = [
new HtmlWebpackPlugin({
inject: true,
hash: true,
chunks: ['index'],
attributes: {
'data-src': function (tag, compilation, index) {
if (tag.tagName === 'script') {
return true;
}
return false;
}
},
}),
new htmlWebpackInjectAttributesPlugin()
]
style tags do not be affected
// vue.config.js
const htmlInject = require('html-webpack-inject-attributes-plugin')
module.exports = {
chainWebpack: (config) => {
config.plugin('html')
.tap(args => {
args[0].attributes = {
async: true,
inject: 'true'
}
return args
})
config.plugin('html-inject')
.after('html')
.use(htmlInject, [{
common: 'true'
}])
},
}
FAQs
add custom attributes to inject script and link
The npm package html-webpack-inject-attributes-plugin receives a total of 16,798 weekly downloads. As such, html-webpack-inject-attributes-plugin popularity was classified as popular.
We found that html-webpack-inject-attributes-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.