config-yargs.js 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. var CONFIG_GROUP = "Config options:";
  2. var BASIC_GROUP = "Basic options:";
  3. var MODULE_GROUP = "Module options:";
  4. var OUTPUT_GROUP = "Output options:";
  5. var ADVANCED_GROUP = "Advanced options:";
  6. var RESOLVE_GROUP = "Resolving options:";
  7. var OPTIMIZE_GROUP = "Optimizing options:";
  8. module.exports = function(yargs) {
  9. yargs
  10. .help("help")
  11. .alias("help", "h")
  12. .version()
  13. .alias("version", "v")
  14. .options({
  15. "config": {
  16. type: "string",
  17. describe: "Path to the config file",
  18. group: CONFIG_GROUP,
  19. defaultDescription: "webpack.config.js or webpackfile.js",
  20. requiresArg: true
  21. },
  22. "config-name": {
  23. type: "string",
  24. describe: "Name of the config to use",
  25. group: CONFIG_GROUP,
  26. requiresArg: true
  27. },
  28. "env": {
  29. describe: "Environment passed to the config, when it is a function",
  30. group: CONFIG_GROUP
  31. },
  32. "context": {
  33. type: "string",
  34. describe: "The root directory for resolving entry point and stats",
  35. group: BASIC_GROUP,
  36. defaultDescription: "The current directory",
  37. requiresArg: true
  38. },
  39. "entry": {
  40. type: "string",
  41. describe: "The entry point",
  42. group: BASIC_GROUP,
  43. requiresArg: true
  44. },
  45. "module-bind": {
  46. type: "string",
  47. describe: "Bind an extension to a loader",
  48. group: MODULE_GROUP,
  49. requiresArg: true
  50. },
  51. "module-bind-post": {
  52. type: "string",
  53. describe: "",
  54. group: MODULE_GROUP,
  55. requiresArg: true
  56. },
  57. "module-bind-pre": {
  58. type: "string",
  59. describe: "",
  60. group: MODULE_GROUP,
  61. requiresArg: true
  62. },
  63. "output-path": {
  64. type: "string",
  65. describe: "The output path for compilation assets",
  66. group: OUTPUT_GROUP,
  67. defaultDescription: "The current directory",
  68. requiresArg: true
  69. },
  70. "output-filename": {
  71. type: "string",
  72. describe: "The output filename of the bundle",
  73. group: OUTPUT_GROUP,
  74. defaultDescription: "[name].js",
  75. requiresArg: true
  76. },
  77. "output-chunk-filename": {
  78. type: "string",
  79. describe: "The output filename for additional chunks",
  80. group: OUTPUT_GROUP,
  81. defaultDescription: "filename with [id] instead of [name] or [id] prefixed",
  82. requiresArg: true
  83. },
  84. "output-source-map-filename": {
  85. type: "string",
  86. describe: "The output filename for the SourceMap",
  87. group: OUTPUT_GROUP,
  88. requiresArg: true
  89. },
  90. "output-public-path": {
  91. type: "string",
  92. describe: "The public path for the assets",
  93. group: OUTPUT_GROUP,
  94. requiresArg: true
  95. },
  96. "output-jsonp-function": {
  97. type: "string",
  98. describe: "The name of the jsonp function used for chunk loading",
  99. group: OUTPUT_GROUP,
  100. requiresArg: true
  101. },
  102. "output-pathinfo": {
  103. type: "boolean",
  104. describe: "Include a comment with the request for every dependency (require, import, etc.)",
  105. group: OUTPUT_GROUP
  106. },
  107. "output-library": {
  108. type: "string",
  109. describe: "Expose the exports of the entry point as library",
  110. group: OUTPUT_GROUP,
  111. requiresArg: true
  112. },
  113. "output-library-target": {
  114. type: "string",
  115. describe: "The type for exposing the exports of the entry point as library",
  116. group: OUTPUT_GROUP,
  117. requiresArg: true
  118. },
  119. "records-input-path": {
  120. type: "string",
  121. describe: "Path to the records file (reading)",
  122. group: ADVANCED_GROUP,
  123. requiresArg: true
  124. },
  125. "records-output-path": {
  126. type: "string",
  127. describe: "Path to the records file (writing)",
  128. group: ADVANCED_GROUP,
  129. requiresArg: true
  130. },
  131. "records-path": {
  132. type: "string",
  133. describe: "Path to the records file",
  134. group: ADVANCED_GROUP,
  135. requiresArg: true
  136. },
  137. "define": {
  138. type: "string",
  139. describe: "Define any free var in the bundle",
  140. group: ADVANCED_GROUP,
  141. requiresArg: true
  142. },
  143. "target": {
  144. type: "string",
  145. describe: "The targeted execution environment",
  146. group: ADVANCED_GROUP,
  147. requiresArg: true
  148. },
  149. "cache": {
  150. type: "boolean",
  151. describe: "Enable in memory caching",
  152. default: null,
  153. group: ADVANCED_GROUP,
  154. defaultDescription: "It's enabled by default when watching"
  155. },
  156. "watch": {
  157. type: "boolean",
  158. alias: "w",
  159. describe: "Watch the filesystem for changes",
  160. group: BASIC_GROUP
  161. },
  162. "watch-stdin": {
  163. type: "boolean",
  164. alias: "stdin",
  165. describe: "Exit the process when stdin is closed",
  166. group: ADVANCED_GROUP
  167. },
  168. "watch-aggregate-timeout": {
  169. describe: "Timeout for gathering changes while watching",
  170. group: ADVANCED_GROUP,
  171. requiresArg: true
  172. },
  173. "watch-poll": {
  174. type: "string",
  175. describe: "The polling interval for watching (also enable polling)",
  176. group: ADVANCED_GROUP
  177. },
  178. "hot": {
  179. type: "boolean",
  180. describe: "Enables Hot Module Replacement",
  181. group: ADVANCED_GROUP
  182. },
  183. "debug": {
  184. type: "boolean",
  185. describe: "Switch loaders to debug mode",
  186. group: BASIC_GROUP
  187. },
  188. "devtool": {
  189. type: "string",
  190. describe: "Enable devtool for better debugging experience (Example: --devtool eval-cheap-module-source-map)",
  191. group: BASIC_GROUP,
  192. requiresArg: true
  193. },
  194. "resolve-alias": {
  195. type: "string",
  196. describe: "Setup a module alias for resolving (Example: jquery-plugin=jquery.plugin)",
  197. group: RESOLVE_GROUP,
  198. requiresArg: true
  199. },
  200. "resolve-extensions": {
  201. "type": "array",
  202. describe: "Setup extensions that should be used to resolve modules (Example: --resolve-extensions .es6,.js)",
  203. group: RESOLVE_GROUP,
  204. requiresArg: true
  205. },
  206. "resolve-loader-alias": {
  207. type: "string",
  208. describe: "Setup a loader alias for resolving",
  209. group: RESOLVE_GROUP,
  210. requiresArg: true
  211. },
  212. "optimize-max-chunks": {
  213. describe: "Try to keep the chunk count below a limit",
  214. group: OPTIMIZE_GROUP,
  215. requiresArg: true
  216. },
  217. "optimize-min-chunk-size": {
  218. describe: "Try to keep the chunk size above a limit",
  219. group: OPTIMIZE_GROUP,
  220. requiresArg: true
  221. },
  222. "optimize-minimize": {
  223. type: "boolean",
  224. describe: "Minimize javascript and switches loaders to minimizing",
  225. group: OPTIMIZE_GROUP
  226. },
  227. "prefetch": {
  228. type: "string",
  229. describe: "Prefetch this request (Example: --prefetch ./file.js)",
  230. group: ADVANCED_GROUP,
  231. requiresArg: true
  232. },
  233. "provide": {
  234. type: "string",
  235. describe: "Provide these modules as free vars in all modules (Example: --provide jQuery=jquery)",
  236. group: ADVANCED_GROUP,
  237. requiresArg: true
  238. },
  239. "labeled-modules": {
  240. type: "boolean",
  241. describe: "Enables labeled modules",
  242. group: ADVANCED_GROUP
  243. },
  244. "plugin": {
  245. type: "string",
  246. describe: "Load this plugin",
  247. group: ADVANCED_GROUP,
  248. requiresArg: true
  249. },
  250. "bail": {
  251. type: "boolean",
  252. describe: "Abort the compilation on first error",
  253. group: ADVANCED_GROUP,
  254. default: null
  255. },
  256. "profile": {
  257. type: "boolean",
  258. describe: "Profile the compilation and include information in stats",
  259. group: ADVANCED_GROUP,
  260. default: null
  261. },
  262. "d": {
  263. type: "boolean",
  264. describe: "shortcut for --debug --devtool eval-cheap-module-source-map --output-pathinfo",
  265. group: BASIC_GROUP
  266. },
  267. "p": {
  268. type: "boolean",
  269. describe: "shortcut for --optimize-minimize --define process.env.NODE_ENV=\"production\"",
  270. group: BASIC_GROUP
  271. }
  272. }).strict();
  273. };