Skip to content
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

Retrieve information for CLI option from webpack schema options file #392

Merged
merged 2 commits into from
Apr 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 34 additions & 36 deletions bin/config-yargs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const optionsSchema = require("webpack/schemas/WebpackOptions.json");
const CONFIG_GROUP = "Config options:";
const BASIC_GROUP = "Basic options:";
const MODULE_GROUP = "Module options:";
Expand Down Expand Up @@ -87,22 +88,22 @@ module.exports = function(yargs) {
group: CONFIG_GROUP
},
mode: {
type: "string",
choices: ["development", "production", "none"],
describe: "Mode to use",
type: optionsSchema.properties.mode.type,
choices: optionsSchema.properties.mode.enum,
describe: optionsSchema.properties.mode.description,
group: CONFIG_GROUP,
requiresArg: true
},
context: {
type: "string",
describe: "The root directory for resolving entry point and stats",
type: optionsSchema.properties.context.type,
describe: optionsSchema.properties.context.description,
group: BASIC_GROUP,
defaultDescription: "The current directory",
requiresArg: true
},
entry: {
type: "string",
describe: "The entry point",
describe: optionsSchema.properties.entry.description,
group: BASIC_GROUP,
requiresArg: true
},
Expand Down Expand Up @@ -132,48 +133,47 @@ module.exports = function(yargs) {
},
"output-path": {
type: "string",
describe: "The output path for compilation assets",
describe: optionsSchema.definitions.output.properties.path.description,
group: OUTPUT_GROUP,
defaultDescription: "The current directory",
requiresArg: true
},
"output-filename": {
type: "string",
describe: "The output filename of the bundle",
describe: optionsSchema.definitions.output.properties.filename.description,
group: OUTPUT_GROUP,
defaultDescription: "[name].js",
requiresArg: true
},
"output-chunk-filename": {
type: "string",
describe: "The output filename for additional chunks",
describe: optionsSchema.definitions.output.properties.chunkFilename.description,
group: OUTPUT_GROUP,
defaultDescription:
"filename with [id] instead of [name] or [id] prefixed",
requiresArg: true
},
"output-source-map-filename": {
type: "string",
describe: "The output filename for the SourceMap",
describe: optionsSchema.definitions.output.properties.sourceMapFilename.description,
group: OUTPUT_GROUP,
requiresArg: true
},
"output-public-path": {
type: "string",
describe: "The public path for the assets",
describe: optionsSchema.definitions.output.properties.publicPath.description,
group: OUTPUT_GROUP,
requiresArg: true
},
"output-jsonp-function": {
type: "string",
describe: "The name of the jsonp function used for chunk loading",
describe: optionsSchema.definitions.output.properties.jsonpFunction.description,
group: OUTPUT_GROUP,
requiresArg: true
},
"output-pathinfo": {
type: "boolean",
describe:
"Include a comment with the request for every dependency (require, import, etc.)",
describe: optionsSchema.definitions.output.properties.pathinfo.description,
group: OUTPUT_GROUP
},
"output-library": {
Expand All @@ -184,26 +184,26 @@ module.exports = function(yargs) {
},
"output-library-target": {
type: "string",
describe:
"The type for exposing the exports of the entry point as library",
describe: optionsSchema.definitions.output.properties.libraryTarget.description,
choices: optionsSchema.definitions.output.properties.libraryTarget.enum,
group: OUTPUT_GROUP,
requiresArg: true
},
"records-input-path": {
type: "string",
describe: "Path to the records file (reading)",
describe: optionsSchema.properties.recordsInputPath.description,
group: ADVANCED_GROUP,
requiresArg: true
},
"records-output-path": {
type: "string",
describe: "Path to the records file (writing)",
describe: optionsSchema.properties.recordsOutputPath.description,
group: ADVANCED_GROUP,
requiresArg: true
},
"records-path": {
type: "string",
describe: "Path to the records file",
describe: optionsSchema.properties.recordsPath.description,
group: ADVANCED_GROUP,
requiresArg: true
},
Expand All @@ -215,37 +215,38 @@ module.exports = function(yargs) {
},
target: {
type: "string",
describe: "The targeted execution environment",
describe: optionsSchema.properties.target.description,
group: ADVANCED_GROUP,
requiresArg: true
},
cache: {
type: "boolean",
describe: "Enable in memory caching",
describe: optionsSchema.properties.cache.description,
default: null,
group: ADVANCED_GROUP,
defaultDescription: "It's enabled by default when watching"
},
watch: {
type: "boolean",
alias: "w",
describe: "Watch the filesystem for changes",
describe: optionsSchema.properties.watch.description,
group: BASIC_GROUP
},
"watch-stdin": {
type: "boolean",
alias: "stdin",
describe: "Exit the process when stdin is closed",
describe: optionsSchema.properties.watchOptions.properties.stdin.description,
group: ADVANCED_GROUP
},
"watch-aggregate-timeout": {
describe: "Timeout for gathering changes while watching",
describe: optionsSchema.properties.watchOptions.properties.aggregateTimeout.description,
type: optionsSchema.properties.watchOptions.properties.aggregateTimeout.type,
group: ADVANCED_GROUP,
requiresArg: true
},
"watch-poll": {
type: "string",
describe: "The polling interval for watching (also enable polling)",
describe: optionsSchema.properties.watchOptions.properties.poll.description,
group: ADVANCED_GROUP
},
hot: {
Expand All @@ -260,22 +261,19 @@ module.exports = function(yargs) {
},
devtool: {
type: "string",
describe:
"Enable devtool for better debugging experience (Example: --devtool eval-cheap-module-source-map)",
describe: optionsSchema.properties.devtool.description,
group: BASIC_GROUP,
requiresArg: true
},
"resolve-alias": {
type: "string",
describe:
"Setup a module alias for resolving (Example: jquery-plugin=jquery.plugin)",
describe: optionsSchema.definitions.resolve.properties.alias.description,
group: RESOLVE_GROUP,
requiresArg: true
},
"resolve-extensions": {
type: "array",
describe:
"Setup extensions that should be used to resolve modules (Example: --resolve-extensions .es6,.js)",
describe: optionsSchema.definitions.resolve.properties.alias.description,
group: RESOLVE_GROUP,
requiresArg: true
},
Expand All @@ -291,13 +289,13 @@ module.exports = function(yargs) {
requiresArg: true
},
"optimize-min-chunk-size": {
describe: "Try to keep the chunk size above a limit",
describe: optionsSchema.properties.optimization.properties.splitChunks.oneOf[1].properties.minSize.description,
group: OPTIMIZE_GROUP,
requiresArg: true
},
"optimize-minimize": {
type: "boolean",
describe: "Minimize javascript and switches loaders to minimizing",
describe: optionsSchema.properties.optimization.properties.minimize.description,
group: OPTIMIZE_GROUP
},
prefetch: {
Expand Down Expand Up @@ -325,14 +323,14 @@ module.exports = function(yargs) {
requiresArg: true
},
bail: {
type: "boolean",
describe: "Abort the compilation on first error",
type: optionsSchema.properties.bail.type,
describe: optionsSchema.properties.bail.description,
group: ADVANCED_GROUP,
default: null
},
profile: {
type: "boolean",
describe: "Profile the compilation and include information in stats",
describe: optionsSchema.properties.profile.description,
group: ADVANCED_GROUP,
default: null
},
Expand Down