Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
update-chunk-links-in-files-webpack-plugin
Advanced tools
a WebPack plugin which updates chunk links in HTML/PHP/ASPX files
This plugin replaces chunk file names (links) in given list of files.
It's meant to solve the problem of updating file names inside HTML / ASPX / PHP / etc. files when chunk names contain a hash, which changes every time a new version of the file is created by WebPack.
In case you are not using Webpack to build your HTML / ASPX / PHP files, this plugin will solve that problem!
$ npm install update-chunk-links-in-files-webpack-plugin --save-dev
First let's have a look at WebPack config file (unimportant bits are omitted for brevity).
Notice that the file names in the output
section contain [contenthash]
, which changes each time the content of the file changes.
const path = require('path');
const UpdateChunkLinksInFilesWebpackPlugin = require('update-chunk-links-in-files-webpack-plugin');
module.exports = {
entry: {
"app": path.resolve("src/index.js")
},
output: {
// chunk names contain `contenthash`
filename: "[name].[contenthash].bundle.js",
chunkFilename: "[name].[contenthash].bundle.js"
},
/* ... your usual WebPack stuff goes here ... */
plugins: [
new UpdateChunkLinksInFilesWebpackPlugin({
// files containing links to chunks, which need to be updated
replaceInFiles: [
path.resolve(__dirname, '_site/master-pages/default.aspx')
],
// regexp patterns to be used to find chunk names in the file
chunkNamePatterns: [
/vendor\.[a-z0-9]+\.bundle\.js/g,
/app\.[a-z0-9]+\.bundle\.js/g
],
// (optional) regexp anti-patterns which can be used to exclude
// chunk names from being inserted into HTML ... i.e. source maps
chunkNameAntiPatterns: [
/vendor\.[a-z0-9]+\.bundle\.js.map/g,
/app\.[a-z0-9]+\.bundle\.js.map/g
]
})
]
};
The following snippet shows the default.aspx
file, which is indicated in the WebPack config
Each time any of the bundle files changes the plugin will update the ASPX file accordingly.
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<p>Hello World</p>
<script src="/script/vendor.0f8f98e02847fe61032d.bundle.js"></script>
<script src="/script/app.f0c4c1d45df3e888a309.bundle.js" async></script>
</body>
</html>
MIT
FAQs
a WebPack plugin which updates chunk links in HTML/PHP/ASPX files
The npm package update-chunk-links-in-files-webpack-plugin receives a total of 1 weekly downloads. As such, update-chunk-links-in-files-webpack-plugin popularity was classified as not popular.
We found that update-chunk-links-in-files-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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.