config-yargs.js 7.0 KB

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