Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
all-chunks-loaded-webpack-plugin
Advanced tools
Provide callback executed after all chunks loaded
Provide callback executed after all chunks loaded.
npm install --save-dev all-chunks-loaded-webpack-plugin
The plugin will update all your webpack
chunks with attribute onload
contains onload callback. Just add the plugin to your webpack config as follows:
webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin')
const AllChunksLoadedWebpackPlugin = require('all-chunks-loaded-webpack-plugin');
module.exports = {
...
plugins: [
new HtmlWebpackPlugin(),
new AllChunksLoadedWebpackPlugin({
callback: "alert('All chunks loaded!');"
}),
...
]
}
This will generate a file dist/index.html
containing the following:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Webpack App</title>
<script type="text/javascript">
var allChunksLoadedWebpackPluginLoadedFiles = [];
function allChunksLoadedWebpackPlugin(chunk, file) {
var allFiles = ['app.css', 'app.js'];
if(allChunksLoadedWebpackPluginLoadedFiles.indexOf(file) === -1) {
allChunksLoadedWebpackPluginLoadedFiles.push(file);
if(allChunksLoadedWebpackPluginLoadedFiles.length === allFiles.length) {
setTimeout(function() {
alert('All chunks loaded!');
}, 0);
}
}
}
</script>
<link href="app.css" rel="stylesheet" onload="this.onload=null;allChunksLoadedWebpackPlugin('app', 'app.css');">
</head>
<body>
<script src="app.js" onload="this.onload=null;allChunksLoadedWebpackPlugin('app', 'app.js');"></script>
</body>
</html>
You can pass a hash of configuration options to all-chunks-loaded-webpack-plugin
. Allowed values are as follows:
Name | Type | Default | Description |
---|---|---|---|
callback | {String} | undefined | Your callback called after all chunks loaded |
errorCallback | {String} | undefined | Your callback called if some chunk has loading error |
chunks | {String[]} | undefined | Allows you to callback called only some chunks loaded |
excludeChunks | {String[]} | undefined | Allows you to skip callback called some chunks loaded |
Here's an example webpack
config illustrating how to use these options:
webpack.config.js
module.exports = {
...
plugins: [
new HtmlWebpackPlugin(),
new AllChunksLoadedWebpackPlugin({
callback: '/* Put your callback here */'
}),
...
]
}
Welcome to issues!
FAQs
Provide callback executed after all chunks loaded
The npm package all-chunks-loaded-webpack-plugin receives a total of 1 weekly downloads. As such, all-chunks-loaded-webpack-plugin popularity was classified as not popular.
We found that all-chunks-loaded-webpack-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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.