@@ -303,11 +303,10 @@ if invoked without arguments it prints a usage:
303303Usage: webpack <options> <input> <output>
304304
305305Options:
306- --single Disable Code Splitting [boolean] [default: false]
307306 --min Minimize it with uglifyjs [boolean] [default: false]
308307 --filenames Output Filenames Into File [boolean] [default: false]
309308 --options Options JSON File [string]
310- --script-src- prefix Path Prefix For JavaScript Loading [string]
309+ --public- prefix Path Prefix For JavaScript Loading [string]
311310 --libary Stores the exports into this variable [string]
312311 --colors Output Stats with colors [boolean] [default: false]
313312 --json Output Stats as JSON [boolean] [default: false]
@@ -330,87 +329,143 @@ webpack(absoluteModulePath, [options], callback)
330329
331330You can also save this options object in a JSON file and use it with the shell command.
332331
333- ` outputJsonpFunction `
334-
335- JSONP function used to load chunks
336-
337- ` scriptSrcPrefix `
338-
339- Path from where chunks are loaded
340-
341- ` outputDirectory `
342-
343- write files to this directory (absolute path)
344-
345- ` output `
346-
347- write first chunk to this file
348-
349- ` outputPostfix `
350-
351- write chunks to files named chunkId plus outputPostfix
352-
353- ` libary `
354-
355- exports of input file are stored in this variable
356-
357- ` minimize `
358-
359- minimize outputs with uglify-js
360-
361- ` debug `
362-
363- prints debug info to output files.
364-
365- ` watch `
366-
367- recompiles on changes (except loaders)
368-
369- ` includeFilenames `
370-
371- add absolute filenames of input files as comments
372-
373- ` resolve.alias ` (object)
374-
375- replace a module. ex. ` {"old-module": "new-module"} `
376-
377- ` resolve.paths ` (array)
378-
379- search paths
380-
381- ` resolve.extensions ` (object)
382-
383- possible extensions for files
384-
385- default: ` ["", ".webpack.js", ".web.js", ".js"] `
386-
387- ` resolve.loaders ` (array)
388-
389- extension to loader mappings. ex. ` [{test: /\.extension$/, loader: "myloader"}] `
390-
391- loads files that matches the RegExp to the loader if no other loader set
392-
393- ` resolve.loaderExtensions ` (array)
394-
395- possible extensions for loaders
396-
397- default: ` [".webpack-web-loader.js", ".webpack-loader.js", ".web-loader.js", ".loader.js", "", ".js"] `
398-
399- ` resolve.loaderPostfixes ` (array)
400-
401- possible postfixes for loaders
402-
403- default: ` ["-webpack-web-loader", "-webpack-loader", "-web-loader", "-loader", ""] `
404-
405- ` parse.overwrites ` (object)
406-
407- free module variables which are replaced with a module. ex. ` { "$": "jquery" } `
332+ ``` javascript
333+ {
334+ output: " out/file.js" , // required
335+ // output file to initial chunk
336+
337+ outputDirectory: " out/dir" , // default: extract directory from output
338+ // output directory for file
339+
340+ outputPostfix: " .chunk.js" , // default: "." + output
341+ // postfix appended to id of lazy loaded chunks
342+
343+ ouputJsonpFunction: " myJsonp" , // default: "webpackJsonp"
344+ // jsonp function used for lazy loaded chunks,
345+ // should be unique for all instances of webpack in a page
346+
347+ publicPrefix: " http://static.url.com/asserts/" , // default: ""
348+ // path to create the chunks url relative to page
349+ // deprecated name: scriptSrcPrefix
350+
351+ libary: " mylib" , // default: null
352+ // store the exports of the entrace module in a variable of this name
353+ // use this to create a libary from webpack
354+
355+ includeFilenames: true , // default: false
356+ // include the filename of each module as comment before the module
357+
358+ watch: true , // default: false
359+ // recompiles on changes on module and contexts (currently not on loaders)
360+
361+ watchDelay: 1000 , // default: 200
362+ // delay in ms before recompile after the last file change
363+
364+ events: new EventEmitter (), // default: new EventEmitter()
365+ // EventEmitter on which events for the compile process are fired
366+ // events: "bundle", "module", "context", "task", "task-end"
367+
368+ parse: {
369+ // options for parsing
370+
371+ overwrites: {
372+ " myglobal" : " modulename-of-myglobal"
373+ // defaults: (defaults are also included if you define your own)
374+ // process: "__webpack_process",
375+ // module: "__webpack_module",
376+ // console: "__webpack_console",
377+ // global: "__webpack_global",
378+ // Buffer: "buffer+.Buffer" // -> require("buffer").Buffer
379+ // "__dirname": "__webpack_dirname",
380+ // "__filename": "__webpack_filename"
381+ },
382+ // inject a free variable named "myglobal" which are required as
383+ // require("modulename-of-myglobal")
384+ // to each module which uses "myglobal"
385+ }
386+
387+ resolve: {
388+ // options for resolving
389+
390+ paths: [" /my/absolute/dirname" ],
391+ // default: (defaults are also included if you define your own)
392+ // [".../buildin",
393+ // ".../buildin/web_modules", ".../buildin/name_modules",
394+ // ".../node_modules"]
395+ // search paths for modules
396+
397+ alias: {
398+ " old-module" : " new-module"
399+ },
400+ // replace a module
401+
402+ extensions: [" " , " .www.js" , " .js" ],
403+ // defaults: (defaults are NOT included if you define your own)
404+ // ["", ".webpack.js", ".web.js", ".js"]
405+ // postfixes for files to try
406+
407+ loaderExtensions: [" .loader.js" , " .www-loader.js" , " " , " .js" ],
408+ // defaults: (defaults are NOT included if you define your own)
409+ // [".webpack-web-loader.js", ".webpack-loader.js",
410+ // ".web-loader.js", ".loader.js", "", ".js"]
411+ // postfixes for loaders to try
412+
413+ loaderPostfixes: [" -loader" , " -xyz" , " " ],
414+ // defaults: (defaults are NOT included if you define your own)
415+ // ["-webpack-web-loader", "-webpack-loader",
416+ // "-web-loader", "-loader", ""]
417+ // postfixes for loader modules to try
418+
419+ loaders: [{test: / \. generator. js/ , loader: " val" }],
420+ // default: (defaults are also included if you define your own)
421+ // [{test: /\.coffee$/, loader: "coffee"},
422+ // {test: /\.json$/, loader: "json"},
423+ // {test: /\.jade$/, loader: "jade"},
424+ // {test: /\.css$/, loader: "style!css"},
425+ // {test: /\.less$/, loader: "style!css!val!less"}]
426+ // automatically use loaders if filename match RegExp
427+ // and no loader is specified
428+ }
429+ }
430+ ```
408431
409432#### ` callback `
410433
411434` function(err, source / stats) `
412- ` source ` if ` options.output ` is not set
413- else ` stats ` as json see [ example] ( /sokra/modules-webpack/tree/master/examples/code-splitting )
435+ ` source ` if ` options.output ` is not set (DEPRECATED)
436+ else ` stats ` as json:
437+
438+ ``` javascript
439+ {
440+ hash: " 52bd9213...38d" ,
441+ chunkCount: 2 ,
442+ modulesCount: 10 ,
443+ modulesIncludingDuplicates: 10 ,
444+ modulesFirstChunk: 3 ,
445+ fileSizes: {
446+ " output.js" : 1234 ,
447+ " 1.output.js" : 2345
448+ },
449+ warnings: [ " Some warning" ],
450+ errors: [ " Some error" ],
451+ fileModules: {
452+ " output.js" : [
453+ { id: 0 , size: 123 , filename: " /home/.../main.js" , reasons: [
454+ { type: " main" }
455+ ]},
456+ { id: 1 , size: 234 , filename: " ..." , reasons: [
457+ { type: " require" , // or "context", "async require", "async context"
458+ count: 2 ,
459+ filename: " /home/.../main.js" ,
460+ // or dirname: "..." // for type = "context" or "async context"
461+ }
462+ ]},
463+ ...
464+ ],
465+ " 1.output.js" : [... ]
466+ }
467+ }
468+ ```
414469
415470## Bonus features
416471
0 commit comments