Skip to content

Commit

Permalink
fix: respect infastructureLogging.level for client.logging
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Aug 11, 2021
1 parent 1307332 commit f5c319c
Show file tree
Hide file tree
Showing 5 changed files with 493 additions and 7 deletions.
12 changes: 12 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ class Server {
...options.client.overlay,
};
}

// Respect infrastructureLogging.level
if (typeof options.client.logging === "undefined") {
const configWithInfrastructureLogging =
configArray.find(
(config) =>
config.infrastructureLogging && config.infrastructureLogging.level
) || configArray[0];

options.client.logging =
configWithInfrastructureLogging.infrastructureLogging.level;
}
}

if (typeof options.compress === "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/simple-config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ module.exports = {
},
node: false,
infrastructureLogging: {
level: "warn",
level: "info",
},
};
60 changes: 60 additions & 0 deletions test/server/Server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,66 @@ describe("Server", () => {
},
},
},
{
title:
"single compiler client.logging should default to infrastructureLogging.level",
multiCompiler: false,
options: {},
webpackConfig: {
infrastructureLogging: {
level: "verbose",
},
},
},
{
title:
"single compiler client.logging should override to infrastructureLogging.level",
multiCompiler: false,
options: {
client: {
logging: "none",
},
},
webpackConfig: {
infrastructureLogging: {
level: "verbose",
},
},
},
{
title:
"multi compiler client.logging should respect infrastructureLogging.level",
multiCompiler: true,
options: {},
webpackConfig: [
{},
// infrastructureLogging is set on the second compiler
{
infrastructureLogging: {
level: "warn",
},
},
],
},
{
title:
"multi compiler client.logging should override infrastructureLogging.level",
multiCompiler: true,
options: {
client: {
logging: "none",
},
},
webpackConfig: [
{},
// infrastructureLogging is set on the second compiler
{
infrastructureLogging: {
level: "warn",
},
},
],
},
{
title: "liveReload is true",
multiCompiler: false,
Expand Down
Loading

0 comments on commit f5c319c

Please sign in to comment.