Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack-dynamic-hash

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-dynamic-hash - npm Package Compare versions

Comparing version 1.0.2 to 1.0.4

.npmignore

61

index.js

@@ -5,13 +5,58 @@ /**

*/
function HelloWorldPlugin(options) {
function WebpackDynamicHash(options) {
// Setup the plugin instance with options...
console.log('hello')
}
//HelloWorldPlugin.prototype.apply = function(compiler) {
// compiler.plugin('done', function() {
// console.log('Hello World!');
// });
//};
WebpackDynamicHash.prototype.apply = function(compiler) {
compiler.plugin('done', function(stats) {
var fs = require('fs');
var json = stats.toJson(); //webpack build的输出文件
var commonshash = ''; //commons.js的 hash
var apphash = ''; //stdapp.js的 hash
var csshash = ''; //css.js的 hash
// node 命令中包涵 -dev
var isDev = (function () {
var argv = process.argv;
for (var i = 0, l = argv.length; i < l; i += 1) {
if (argv[i] === '-dev') {
return true;
}
}
})();
var commonsStats = json.assetsByChunkName['commons'];
if (commonsStats) {
// -dev commons输出的是数组
if (isDev) {
commonshash = '?' + commonsStats[0].split('?')[1];
} else {
commonshash = '?' + commonsStats.split('?')[1];
}
}
var appHash = function (appname) {
var appStats = json.assetsByChunkName[appname];
var appStatsLength = appStats.length;
if (appStatsLength) {
for (var i = 0; i < appStatsLength; i += 1) {
if (appStats[i].indexOf(appname + '.js') > -1 && appStats[i].indexOf(appname + '.js.map') === -1) {
apphash = '?' + appStats[i].split('?')[1];
} else if (appStats[i].indexOf(appname + '.css') > -1 && appStats[i].indexOf(appname + '.css.map') === -1) {
csshash = '?' + appStats[i].split('?')[1];
}
}
}
};
var changeFile = function (init, app, css) {
var text = fs.readFileSync(path.join(__dirname, init), 'utf8');
var out = text.replace('?commonshash', commonshash);
out = out.replace(app, apphash);
out = out.replace(css, csshash);
fs.writeFileSync(path.join(__dirname, init), out);
};
appHash('std-app');
appHash('licai-app');
changeFile('build/js/std-init.js', '?apphash', '?csshash');
changeFile('build/js/licai-init.js', '?apphash', '?csshash');
});
};
module.exports = HelloWorldPlugin;
module.exports = WebpackDynamicHash;

2

package.json
{
"name": "webpack-dynamic-hash",
"version": "1.0.2",
"version": "1.0.4",
"main": "index.js",

@@ -5,0 +5,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc