Skip to content

Commit

Permalink
feat(webpack-cli): add no-mode flag
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Feb 27, 2020
1 parent b966e89 commit 68bd64a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/webpack-cli/lib/groups/ZeroConfigGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { logger } = require('@webpack-cli/logger');

const PRODUCTION = 'production';
const DEVELOPMENT = 'development';
const NONE = 'none';
/**
* ZeroConfigGroup creates a zero configuration based on the environment
*/
Expand Down Expand Up @@ -34,6 +35,8 @@ class ZeroConfigGroup extends GroupHelper {
return PRODUCTION;
} else if (this.args.dev) {
return DEVELOPMENT;
} else if (this.args.nomode) {
return NONE;
}
return PRODUCTION;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/webpack-cli/lib/utils/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ module.exports = {
link: 'https://webpack.js.org/concepts/#mode',
acceptedValues: ["development", "production"]
},
{
name: 'nomode',
usage: '--nomode',
type: Boolean,
group: ZERO_CONFIG_GROUP,
description: 'Sets mode="none"',
link: 'https://webpack.js.org/concepts/#mode',
},
{
name: 'version',
usage: '--version',
Expand Down
4 changes: 3 additions & 1 deletion packages/webpack-cli/lib/utils/zero-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function getEnvFromOptionsAndMode(mode, optionsObject) {
const { dev, prod } = optionsObject;
const { dev, prod, nomode } = optionsObject;
const NODE_ENV = process.env.NODE_ENV;
if (NODE_ENV && (NODE_ENV === 'production' || NODE_ENV === 'development')) {
return NODE_ENV;
Expand All @@ -9,6 +9,8 @@ function getEnvFromOptionsAndMode(mode, optionsObject) {
return 'development';
} else if (mode) {
return mode;
} else if (nomode) {
return 'none';
}
return 'production';
}
Expand Down

0 comments on commit 68bd64a

Please sign in to comment.