nav tabs on admin dashboard
This commit is contained in:
101
node_modules/webpack/lib/performance/SizeLimitsPlugin.js
generated
vendored
101
node_modules/webpack/lib/performance/SizeLimitsPlugin.js
generated
vendored
@@ -18,85 +18,88 @@ module.exports = class SizeLimitsPlugin {
|
||||
const entrypointSizeLimit = this.maxEntrypointSize;
|
||||
const assetSizeLimit = this.maxAssetSize;
|
||||
const hints = this.hints;
|
||||
const assetFilter = this.assetFilter || (asset => !(/\.map$/.test(asset)));
|
||||
const assetFilter = this.assetFilter || (asset => !asset.endsWith(".map"));
|
||||
|
||||
compiler.plugin("after-emit", (compilation, callback) => {
|
||||
compiler.hooks.afterEmit.tap("SizeLimitsPlugin", compilation => {
|
||||
const warnings = [];
|
||||
|
||||
const getEntrypointSize = entrypoint =>
|
||||
entrypoint.getFiles()
|
||||
.filter(assetFilter)
|
||||
.map(file => compilation.assets[file])
|
||||
.filter(Boolean)
|
||||
.map(asset => asset.size())
|
||||
.reduce((currentSize, nextSize) => currentSize + nextSize, 0);
|
||||
entrypoint.getFiles().reduce((currentSize, file) => {
|
||||
if (assetFilter(file) && compilation.assets[file]) {
|
||||
return currentSize + compilation.assets[file].size();
|
||||
}
|
||||
|
||||
return currentSize;
|
||||
}, 0);
|
||||
|
||||
const assetsOverSizeLimit = [];
|
||||
Object.keys(compilation.assets)
|
||||
.filter(assetFilter)
|
||||
.forEach(assetName => {
|
||||
const asset = compilation.assets[assetName];
|
||||
const size = asset.size();
|
||||
for (const assetName of Object.keys(compilation.assets)) {
|
||||
if (!assetFilter(assetName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(size > assetSizeLimit) {
|
||||
assetsOverSizeLimit.push({
|
||||
name: assetName,
|
||||
size: size,
|
||||
});
|
||||
asset.isOverSizeLimit = true;
|
||||
}
|
||||
});
|
||||
const asset = compilation.assets[assetName];
|
||||
const size = asset.size();
|
||||
if (size > assetSizeLimit) {
|
||||
assetsOverSizeLimit.push({
|
||||
name: assetName,
|
||||
size: size
|
||||
});
|
||||
asset.isOverSizeLimit = true;
|
||||
}
|
||||
}
|
||||
|
||||
const entrypointsOverLimit = [];
|
||||
Object.keys(compilation.entrypoints)
|
||||
.forEach(key => {
|
||||
const entry = compilation.entrypoints[key];
|
||||
const size = getEntrypointSize(entry, compilation);
|
||||
for (const pair of compilation.entrypoints) {
|
||||
const name = pair[0];
|
||||
const entry = pair[1];
|
||||
const size = getEntrypointSize(entry);
|
||||
|
||||
if(size > entrypointSizeLimit) {
|
||||
entrypointsOverLimit.push({
|
||||
name: key,
|
||||
size: size,
|
||||
files: entry.getFiles().filter(assetFilter)
|
||||
});
|
||||
entry.isOverSizeLimit = true;
|
||||
}
|
||||
});
|
||||
if (size > entrypointSizeLimit) {
|
||||
entrypointsOverLimit.push({
|
||||
name: name,
|
||||
size: size,
|
||||
files: entry.getFiles().filter(assetFilter)
|
||||
});
|
||||
entry.isOverSizeLimit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(hints) {
|
||||
if (hints) {
|
||||
// 1. Individual Chunk: Size < 250kb
|
||||
// 2. Collective Initial Chunks [entrypoint] (Each Set?): Size < 250kb
|
||||
// 3. No Async Chunks
|
||||
// if !1, then 2, if !2 return
|
||||
if(assetsOverSizeLimit.length > 0) {
|
||||
if (assetsOverSizeLimit.length > 0) {
|
||||
warnings.push(
|
||||
new AssetsOverSizeLimitWarning(
|
||||
assetsOverSizeLimit,
|
||||
assetSizeLimit));
|
||||
new AssetsOverSizeLimitWarning(assetsOverSizeLimit, assetSizeLimit)
|
||||
);
|
||||
}
|
||||
if(entrypointsOverLimit.length > 0) {
|
||||
if (entrypointsOverLimit.length > 0) {
|
||||
warnings.push(
|
||||
new EntrypointsOverSizeLimitWarning(
|
||||
entrypointsOverLimit,
|
||||
entrypointSizeLimit));
|
||||
entrypointSizeLimit
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if(warnings.length > 0) {
|
||||
const hasAsyncChunks = compilation.chunks.filter(chunk => !chunk.isInitial()).length > 0;
|
||||
if (warnings.length > 0) {
|
||||
const hasAsyncChunks =
|
||||
compilation.chunks.filter(chunk => !chunk.canBeInitial()).length >
|
||||
0;
|
||||
|
||||
if(!hasAsyncChunks) {
|
||||
if (!hasAsyncChunks) {
|
||||
warnings.push(new NoAsyncChunksWarning());
|
||||
}
|
||||
|
||||
if(hints === "error") {
|
||||
Array.prototype.push.apply(compilation.errors, warnings);
|
||||
if (hints === "error") {
|
||||
compilation.errors.push(...warnings);
|
||||
} else {
|
||||
Array.prototype.push.apply(compilation.warnings, warnings);
|
||||
compilation.warnings.push(...warnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user