diff --git a/lib/Stats.js b/lib/Stats.js
index 7887ed087..064a8e9b2 100644
--- a/lib/Stats.js
+++ b/lib/Stats.js
@@ -418,6 +418,9 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
for(row = 0; row < rows; row++) {
for(col = 0; col < cols; col++) {
value = getText(array, row, col) + "";
+ if(value.length === 0) {
+ colSizes[col] = 0;
+ }
if(value.length > colSizes[col]) {
colSizes[col] = value.length;
}
@@ -434,7 +437,7 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
colors.normal(" ");
if(align[col] === "r")
format(value);
- if(col + 1 < cols)
+ if(col + 1 < cols && colSizes[col] != 0)
colors.normal(splitter || " ");
}
newline();
@@ -446,7 +449,6 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
return colors.yellow;
}
-
return defaultColor;
}
@@ -489,7 +491,7 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
{value: formatSize(asset.size), color: getAssetColor(asset, colors.normal)},
{value: asset.chunks.join(", "), color: colors.bold},
{value: asset.emitted ? "[emitted]" : "", color: colors.green},
- {value: asset.isOverSizeLimit ? "[big]" : "", color: colors.yellow},
+ {value: asset.isOverSizeLimit ? "[big]" : "", color: getAssetColor(asset, colors.normal)},
{value: asset.chunkNames.join(", "), color: colors.normal}
]);
});
diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js
index 6a3bcdb5d..04d585b0e 100644
--- a/lib/WebpackOptionsApply.js
+++ b/lib/WebpackOptionsApply.js
@@ -42,6 +42,7 @@ var FlagIncludedChunksPlugin = require("./optimize/FlagIncludedChunksPlugin");
var OccurrenceOrderPlugin = require("./optimize/OccurrenceOrderPlugin");
var FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin");
var FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
+var EmittedAssetSizeLimitPlugin = require("./performance/EmittedAssetSizeLimitPlugin");
var ResolverFactory = require("enhanced-resolve").ResolverFactory;
@@ -65,28 +66,21 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
compiler.name = options.name;
compiler.dependencies = options.dependencies;
if(typeof options.target === "string") {
- var EmittedAssetSizeLimitPlugin;
var JsonpTemplatePlugin;
var NodeSourcePlugin;
var NodeTargetPlugin;
var NodeTemplatePlugin;
+
switch(options.target) {
case "web":
JsonpTemplatePlugin = require("./JsonpTemplatePlugin");
NodeSourcePlugin = require("./node/NodeSourcePlugin");
-
compiler.apply(
new JsonpTemplatePlugin(options.output),
new FunctionModulePlugin(options.output),
new NodeSourcePlugin(options.node),
new LoaderTargetPlugin("web")
);
-
- if (options.performance.hints) {
- EmittedAssetSizeLimitPlugin = require("./performance/EmittedAssetSizeLimitPlugin");
- compiler.apply(new EmittedAssetSizeLimitPlugin(options.performance));
- }
-
break;
case "webworker":
var WebWorkerTemplatePlugin = require("./webworker/WebWorkerTemplatePlugin");
@@ -194,6 +188,7 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
} else {
throw new Error("Unsupported target '" + options.target + "'.");
}
+
if(options.output.library || options.output.libraryTarget !== "var") {
var LibraryTemplatePlugin = require("./LibraryTemplatePlugin");
compiler.apply(new LibraryTemplatePlugin(options.output.library, options.output.libraryTarget, options.output.umdNamedDefine, options.output.auxiliaryComment || ""));
@@ -272,6 +267,8 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
new FlagDependencyUsagePlugin()
);
+ compiler.apply(new EmittedAssetSizeLimitPlugin(options.performance));
+
compiler.apply(new TemplatedPathPlugin());
compiler.apply(new RecordIdsPlugin());
diff --git a/lib/WebpackOptionsDefaulter.js b/lib/WebpackOptionsDefaulter.js
index fc306ae85..bb3299987 100644
--- a/lib/WebpackOptionsDefaulter.js
+++ b/lib/WebpackOptionsDefaulter.js
@@ -13,11 +13,6 @@ function WebpackOptionsDefaulter() {
this.set("context", process.cwd());
this.set("target", "web");
- this.set("performance.maxAssetSize", 250000);
- this.set("performance.maxInitialChunkSize", 250000);
- this.set("performance.hints", true);
- this.set("performance.errorOnHint", false);
-
this.set("module.unknownContextRequest", ".");
this.set("module.unknownContextRegExp", false);
this.set("module.unknownContextRecursive", true);
@@ -74,6 +69,16 @@ function WebpackOptionsDefaulter() {
this.set("node.__filename", "mock");
this.set("node.__dirname", "mock");
+ this.set("performance.maxAssetSize", 250000);
+ this.set("performance.maxInitialChunkSize", 250000);
+ this.set("performance.errorOnHint", false);
+ this.set("performance.hints", "make", function(options) {
+ if(options.target === "web")
+ return true;
+ else
+ return false;
+ });
+
this.set("resolve", {});
this.set("resolve.unsafeCache", true);
this.set("resolve.modules", ["node_modules"]);
@@ -90,7 +95,6 @@ function WebpackOptionsDefaulter() {
else
return ["module", "main"];
});
-
this.set("resolveLoader", {});
this.set("resolveLoader.unsafeCache", true);
this.set("resolveLoader.mainFields", ["loader", "main"]);
diff --git a/lib/performance/AssetsOverSizeLimitWarning.js b/lib/performance/AssetsOverSizeLimitWarning.js
index c3a10ecc2..05d0de044 100644
--- a/lib/performance/AssetsOverSizeLimitWarning.js
+++ b/lib/performance/AssetsOverSizeLimitWarning.js
@@ -11,7 +11,7 @@ function AssetsOverSizeLimitWarning(assetsOverSizeLimit, assetLimit) {
this.assets = assetsOverSizeLimit;
var assetLists = this.assets.map(function(asset) {
- return "\n " + asset.name + " (" + SizeFormatHelpers.formatSize(asset.size) +")";
+ return "\n " + asset.name + " (" + SizeFormatHelpers.formatSize(asset.size) + ")";
}).join("");
this.message = "asset size limit: The following asset(s) exceed the recommended size limit (" + SizeFormatHelpers.formatSize(assetLimit) + "). \n" +
diff --git a/lib/performance/EmittedAssetSizeLimitPlugin.js b/lib/performance/EmittedAssetSizeLimitPlugin.js
index 5472ab469..fcd1cc0a9 100644
--- a/lib/performance/EmittedAssetSizeLimitPlugin.js
+++ b/lib/performance/EmittedAssetSizeLimitPlugin.js
@@ -54,7 +54,9 @@ EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
}).length > 0;
var entrypointsOverLimit = Object.keys(compilation.entrypoints)
- .map(function(key) { return compilation.entrypoints[key] })
+ .map(function(key) {
+ return compilation.entrypoints[key]
+ })
.filter(function(entry) {
return doesExceedLimit(entrypointSizeLimit, entry.getSize(compilation))
});
@@ -83,7 +85,7 @@ EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
warnings.push(new NoAsyncChunksWarning());
}
} else {
- if(entrypointsOverLimit.legnth > 0) {
+ if(entrypointsOverLimit.length > 0) {
warnings.push(
new EntrypointsOverSizeLimitWarning(
entrypointsOverLimit,
diff --git a/lib/performance/EntrypointsOverSizeLimitWarning.js b/lib/performance/EntrypointsOverSizeLimitWarning.js
index 257b32df1..e2367819f 100644
--- a/lib/performance/EntrypointsOverSizeLimitWarning.js
+++ b/lib/performance/EntrypointsOverSizeLimitWarning.js
@@ -10,7 +10,6 @@ function EntrypointsOverSizeLimitWarning(entrypoints, compilation, entrypointLim
this.name = "EntrypointsOverSizeLimitWarning";
this.entrypoints = entrypoints;
-
var entrypointCompilation = compilation;
var entrypointList = this.entrypoints.map(function(entrypoint) {
return "\n " + entrypoint.name + " (" + SizeFormatHelpers.formatSize(entrypoint.getSize(entrypointCompilation)) + ")\n" +
@@ -19,8 +18,6 @@ function EntrypointsOverSizeLimitWarning(entrypoints, compilation, entrypointLim
}).join("");
}).join("");
- debugger;
-
this.message = "entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (" + SizeFormatHelpers.formatSize(entrypointLimit) + "). " +
"This can impact web performance.\n" +
"Entrypoints:" + entrypointList;
diff --git a/test/statsCases/color-enabled-custom/expected.txt b/test/statsCases/color-enabled-custom/expected.txt
index 61ce914c3..67a46fff2 100644
--- a/test/statsCases/color-enabled-custom/expected.txt
+++ b/test/statsCases/color-enabled-custom/expected.txt
@@ -1,6 +1,6 @@
Hash: 6c781fe6bf412ba6435b
Time: Xms
- Asset Size Chunks Chunk Names
+ Asset Size Chunks Chunk Names
main.js 2.51 kB 0 [emitted] main
chunk {0} main.js (main) 0 bytes [entry] [rendered]
[0] (webpack)/test/statsCases/color-enabled-custom/index.js 0 bytes {0} [built]
\ No newline at end of file
diff --git a/test/statsCases/color-enabled/expected.txt b/test/statsCases/color-enabled/expected.txt
index e8f931085..9054ff587 100644
--- a/test/statsCases/color-enabled/expected.txt
+++ b/test/statsCases/color-enabled/expected.txt
@@ -1,6 +1,6 @@
Hash: 6c781fe6bf412ba6435b
Time: Xms
- Asset Size Chunks Chunk Names
+ Asset Size Chunks Chunk Names
main.js 2.51 kB 0 [emitted] main
chunk {0} main.js (main) 0 bytes [entry] [rendered]
[0] (webpack)/test/statsCases/color-enabled/index.js 0 bytes {0} [built]
\ No newline at end of file
diff --git a/test/statsCases/performance-error/expected.txt b/test/statsCases/performance-error/expected.txt
index 90fa3ee18..82f75e269 100644
--- a/test/statsCases/performance-error/expected.txt
+++ b/test/statsCases/performance-error/expected.txt
@@ -1,9 +1,9 @@
Time: Xms
- Asset Size Chunks Chunk Names
- 0.js 227 bytes 0 [emitted]
- 1.js 106 bytes 1 [emitted]
- 2.js 200 bytes 2 [emitted]
-main.js 306 kB 3 [emitted] main
+ Asset Size Chunks Chunk Names
+ 0.js 227 bytes 0 [emitted]
+ 1.js 106 bytes 1 [emitted]
+ 2.js 200 bytes 2 [emitted]
+main.js 306 kB 3 [emitted] [big] main
chunk {0} 0.js 54 bytes {3} [rendered]
[2] (webpack)/test/statsCases/performance-error/c.js 54 bytes {0} [built]
chunk {1} 1.js 22 bytes {3} [rendered]
@@ -15,14 +15,13 @@ chunk {3} main.js (main) 300 kB(webpack)/test/statsCases/performance-error/a.js 300 kB {3} [built]
[5] (webpack)/test/statsCases/performance-error/index.js 52 bytes {3} [built]
-ERROR in asset size limit: The following assets exceed the recommended size limit (250 kB).
+ERROR in asset size limit: The following asset(s) exceed the recommended size limit (250 kB).
This can impact web performance.
Assets:
- main.js
+ main.js (306 kB)
ERROR in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (250 kB). This can impact web performance.
-Entrypoints:
-
- main: 306 kB
+Entrypoints:
+ main (306 kB)
main.js
\ No newline at end of file
diff --git a/test/statsCases/preset-normal-performance/expected.txt b/test/statsCases/preset-normal-performance/expected.txt
index e85dcc7e4..f89429818 100644
--- a/test/statsCases/preset-normal-performance/expected.txt
+++ b/test/statsCases/preset-normal-performance/expected.txt
@@ -1,9 +1,9 @@
Time: Xms
- Asset Size Chunks Chunk Names
- 0.js 227 bytes 0 [emitted]
- 1.js 106 bytes 1 [emitted]
- 2.js 200 bytes 2 [emitted]
-main.js 306 kB 3 [emitted] main
+ Asset Size Chunks Chunk Names
+ 0.js 227 bytes 0 [emitted]
+ 1.js 106 bytes 1 [emitted]
+ 2.js 200 bytes 2 [emitted]
+main.js 306 kB 3 [emitted] [big] main
chunk {0} 0.js 54 bytes {3} [rendered]
[2] (webpack)/test/statsCases/preset-normal-performance/c.js 54 bytes {0} [built]
chunk {1} 1.js 22 bytes {3} [rendered]
@@ -15,14 +15,13 @@ chunk {3} main.js (main) 300 kB(webpack)/test/statsCases/preset-normal-performance/a.js 300 kB {3} [built]
[5] (webpack)/test/statsCases/preset-normal-performance/index.js 52 bytes {3} [built]
-WARNING in asset size limit: The following assets exceed the recommended size limit (250 kB).
+WARNING in asset size limit: The following asset(s) exceed the recommended size limit (250 kB).
This can impact web performance.
Assets:
- main.js
+ main.js (306 kB)
WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (250 kB). This can impact web performance.
-Entrypoints:
-
- main: 306 kB
+Entrypoints:
+ main (306 kB)
main.js
\ No newline at end of file