diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 5264a2146e5..ce949b3078c 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -1,3 +1,4 @@ +const { logger } = require('@webpack-cli/logger'); const HELP_GROUP = 'help'; const CONFIG_GROUP = 'config'; const BASIC_GROUP = 'basic'; @@ -286,11 +287,16 @@ module.exports = { { name: 'mode', usage: '--mode ', - type: String, + type: (value) => { + if (value === 'development' || value === 'production' || value === 'none') { + return value + } else { + logger.warn('You provided an invalid value for "mode" option.') + } + }, group: ZERO_CONFIG_GROUP, description: 'Defines the mode to pass to webpack', - link: 'https://webpack.js.org/concepts/#mode', - acceptedValues: ["development", "production"] + link: 'https://webpack.js.org/concepts/#mode' }, { name: 'no-mode', diff --git a/test/help/__snapshots__/help-single-arg.test.js.snap b/test/help/__snapshots__/help-single-arg.test.js.snap index 3ef3bcec597..079bf435b25 100644 --- a/test/help/__snapshots__/help-single-arg.test.js.snap +++ b/test/help/__snapshots__/help-single-arg.test.js.snap @@ -44,7 +44,7 @@ Options --standard Prints standard output -d, --dev Run development build -p, --prod Run production build - --mode string Defines the mode to pass to webpack + --mode type Defines the mode to pass to webpack --no-mode Sets mode="none" which disables any default behavior --version Get current version --node-args string[] NodeJS flags