Socket
Socket
Sign inDemoInstall

webpack-manifest-resource-plugin

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-manifest-resource-plugin - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

63

lib/plugin.js

@@ -37,6 +37,6 @@ var path = require('path');

// old version not include publicPath
ManifestPlugin.prototype.normalizeFile = function(manifest, publicPath) {
ManifestPlugin.prototype.normalizeFile = function(manifest, prefix) {
var normalizeManifest = {};
Object.keys(manifest).forEach(key => {
normalizeManifest[key] = manifest[key].replace(publicPath, '');
normalizeManifest[key] = manifest[key].replace(prefix, '');
});

@@ -69,49 +69,37 @@ return normalizeManifest;

ManifestPlugin.prototype.getDeps = function(manifest, commonsChunk) {
const commonScriptPaths = [];
const commonCSSPaths = [];
const manifestDeps = {};
let commonsChunkItemIsString = true;
const deps = {};
const commonChunkScript = [];
const commonChunkCss = [];
commonsChunk.forEach(item => {
commonsChunkItemIsString = typeof item === 'string';
if (commonsChunkItemIsString) {
if (typeof item === 'string') {
const jsKey = `${item}.js`;
const cssKey = `${item}.css`;
manifest[jsKey] && commonScriptPaths.push(manifest[jsKey]);
manifest[cssKey] && commonCSSPaths.push(manifest[cssKey]);
manifest[jsKey] && commonChunkScript.push(manifest[jsKey]);
manifest[cssKey] && commonChunkCss.push(manifest[cssKey]);
}
});
Object.keys(manifest).forEach(pageKey => {
if (/\.js$/.test(pageKey)) {
const dllScript = [];
const dllCss = [];
const pageName = pageKey.replace(/\.js$/, '');
if (commonsChunkItemIsString) {
// 不处理公共 commonsChunk 依赖
if (!commonsChunk.includes(pageName)) {
manifestDeps[pageKey] = {
js: commonScriptPaths.concat(manifest[pageKey]),
css: commonCSSPaths.concat(manifest[pageKey.replace(/\.js$/, '.css')] || []),
};
}
} else {
const pageCommonScriptPaths = [];
const pageCommonCSSPaths = [];
const isCommonsChunk = commonsChunk.find(dll =>{
return dll.name === pageName;
});
commonsChunk.forEach(dll => {
const isCommonsChunk = commonsChunk.find(chunk => {
return chunk === pageName || typeof chunk === 'object' && chunk.name === pageName;
});
commonsChunk.forEach(dll => {
if (typeof dll === 'object') {
if (!isCommonsChunk && this.isMatch(dll.include, pageName, true) && !this.isMatch(dll.exclude, pageName, false)) {
const jsKey = `${dll.name}.js`;
const cssKey = `${dll.name}.css`;
manifest[jsKey] && pageCommonScriptPaths.push(manifest[jsKey]);
manifest[cssKey] && pageCommonCSSPaths.push(manifest[cssKey]);
manifest[jsKey] && dllScript.push(manifest[jsKey]);
manifest[cssKey] && dllCss.push(manifest[cssKey]);
}
});
manifestDeps[pageKey] = {
js: pageCommonScriptPaths.concat(manifest[pageKey]),
css: pageCommonCSSPaths.concat(manifest[pageKey.replace(/\.js$/, '.css')] || []),
};
}
}
});
const js = dllScript.concat(commonChunkScript).concat(manifest[pageKey]);
const css = dllCss.concat(commonChunkCss).concat(manifest[pageKey.replace(/\.js$/, '.css')] || []);
deps[pageKey] = { js, css };
}
});
return manifestDeps;
return deps;
};

@@ -124,5 +112,5 @@

if (manifestDll && typeof manifestDll === 'boolean') {
return normalizeManifest;
return this.normalizeFile(normalizeManifest, this.opts.host);
} else {
const commonsChunk = this.opts.commonsChunk;
let commonsChunk = [];
const dllConfig = this.opts.dllConfig;

@@ -143,2 +131,3 @@ if (dllConfig) { // 合并 dll manifest 到 manifest

}
commonsChunk = commonsChunk.concat(this.opts.commonsChunk);
const depsManifest = this.getDeps(normalizeManifest, commonsChunk);

@@ -145,0 +134,0 @@ return Object.assign({}, normalizeManifest, {

{
"name": "webpack-manifest-resource-plugin",
"version": "2.0.0",
"version": "2.0.1",
"description": "manifest resource dependencies",

@@ -5,0 +5,0 @@ "keywords": [

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