-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore: upgrade dev middleware #2660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f192a40
cab2924
78ebd08
390da6c
8aca25b
7489d41
1d2dad9
bef4800
717bec4
b462d2d
4d26b5d
6c927c7
22d97d5
99e31d9
3c0f598
948a4bc
3f0f0b8
86f6b2a
121d999
db4903e
c8aec00
b657eb1
157a26a
80a34c1
3319b0b
30b3443
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,17 +62,6 @@ const options = { | |
describe: 'Open default browser with the specified page', | ||
requiresArg: true, | ||
}, | ||
color: { | ||
type: 'boolean', | ||
alias: 'colors', | ||
default: function supportsColor() { | ||
// Use `require('supports-color').stdout` for supports-color >= 5.0.0. | ||
// See https://github.com/webpack/webpack-dev-server/pull/1555. | ||
return require('supports-color').stdout; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not forget to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}, | ||
group: DISPLAY_GROUP, | ||
describe: 'Enables/Disables colors on the console', | ||
}, | ||
'client-logging': { | ||
type: 'string', | ||
group: DISPLAY_GROUP, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,16 +47,18 @@ function createConfig(config, argv, { port }) { | |
options.overlay = argv.overlay; | ||
} | ||
|
||
if (!options.publicPath) { | ||
options.dev = options.dev || {}; | ||
|
||
if (!options.dev.publicPath) { | ||
// eslint-disable-next-line | ||
options.publicPath = | ||
options.dev.publicPath = | ||
(firstWpOpt.output && firstWpOpt.output.publicPath) || ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is really bad idea smile But let's resolve it on the other PR |
||
|
||
if ( | ||
!isAbsoluteUrl(String(options.publicPath)) && | ||
options.publicPath[0] !== '/' | ||
!isAbsoluteUrl(String(options.dev.publicPath)) && | ||
options.dev.publicPath[0] !== '/' | ||
) { | ||
options.publicPath = `/${options.publicPath}`; | ||
options.dev.publicPath = `/${options.dev.publicPath}`; | ||
} | ||
} | ||
|
||
|
@@ -111,21 +113,6 @@ function createConfig(config, argv, { port }) { | |
options.watchContentBase = true; | ||
} | ||
|
||
if (!options.stats) { | ||
options.stats = defaultTo(firstWpOpt.stats, { | ||
cached: false, | ||
cachedAssets: false, | ||
}); | ||
} | ||
|
||
if ( | ||
typeof options.stats === 'object' && | ||
typeof options.stats.colors === 'undefined' && | ||
argv.color | ||
) { | ||
options.stats = Object.assign({}, options.stats, { colors: argv.color }); | ||
} | ||
|
||
if (argv.https) { | ||
options.https = true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
const getStatsOption = require('./getStatsOption'); | ||
|
||
function getColorsOption(configArr) { | ||
const statsOption = getStatsOption(configArr); | ||
let colors = false; | ||
if (typeof statsOption === 'object' && statsOption.colors) { | ||
colors = statsOption.colors; | ||
} | ||
|
||
return colors; | ||
} | ||
|
||
module.exports = getColorsOption; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
function getCompilerConfigArray(compiler) { | ||
const compilers = compiler.compilers ? compiler.compilers : [compiler]; | ||
return compilers.map((comp) => comp.options); | ||
} | ||
|
||
module.exports = getCompilerConfigArray; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
function getStatsOption(configArr) { | ||
const isEmptyObject = (val) => | ||
typeof val === 'object' && Object.keys(val).length === 0; | ||
|
||
// in webpack@4 stats will not be defined if not provided, | ||
// but in webpack@5 it will be an empty object | ||
const statsConfig = configArr.find( | ||
(conf) => | ||
typeof conf === 'object' && conf.stats && !isEmptyObject(conf.stats) | ||
); | ||
return statsConfig ? statsConfig.stats : {}; | ||
} | ||
|
||
module.exports = getStatsOption; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the
color
CLI flag since it ends up settingcolors: true
in the stats option, which was also removed.New behavior:
colors
isfalse
(should it betrue
?)stats: { colors: true }
.Do you think we should do this approach, or should we keep the color CLI flag and then update the compiler stats option using this flag?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need this option, default value is
stats.colors
(https://github.com/webpack/webpack/blob/master/lib/stats/DefaultStatsPresetPlugin.js#L168),webpack-cli
should have--stats-colors
(or--colors
) flag to enable or disable it, it is out of scope webpack-dev-server