@@ -6,6 +6,7 @@ contributors:
6
6
- rynclark
7
7
- byzyk
8
8
- wizardofhogwarts
9
+ - EugeneHlushko
9
10
---
10
11
11
12
webpack provides a Node.js API which can be used directly in Node.js runtime.
@@ -39,11 +40,11 @@ import webpack from 'webpack';
39
40
The imported ` webpack ` function is fed a webpack [ Configuration Object] ( /configuration/ ) and runs the webpack compiler if a callback function is provided:
40
41
41
42
``` js-with-links
42
- const webpack = require(" webpack" );
43
+ const webpack = require(' webpack' );
43
44
44
45
webpack({
45
46
// [Configuration Object](/configuration/)
46
- }, (err, [ stats](#stats-object)) => {
47
+ }, (err, stats) => { // [Stats Object ](#stats-object)
47
48
if (err || stats.hasErrors()) {
48
49
// [Handle errors here](#error-handling)
49
50
}
@@ -96,7 +97,7 @@ Calling the `run` method on the `Compiler` instance is much like the quick run
96
97
method mentioned above:
97
98
98
99
``` js-with-links
99
- const webpack = require(" webpack" );
100
+ const webpack = require(' webpack' );
100
101
101
102
const compiler = webpack({
102
103
// [Configuration Object](/configuration/)
@@ -119,7 +120,7 @@ watch(watchOptions, callback);
119
120
```
120
121
121
122
``` js-with-links
122
- const webpack = require(" webpack" );
123
+ const webpack = require(' webpack' );
123
124
124
125
const compiler = webpack({
125
126
// [Configuration Object](/configuration/)
@@ -129,7 +130,7 @@ const watching = compiler.watch({
129
130
// Example [watchOptions](/configuration/watch/#watchoptions)
130
131
aggregateTimeout: 300,
131
132
poll: undefined
132
- }, (err, [ stats](#stats-object)) => {
133
+ }, (err, stats) => { // [Stats Object ](#stats-object)
133
134
// Print watch/build result here...
134
135
console.log(stats);
135
136
});
@@ -207,7 +208,7 @@ Returns compilation information as a JSON object. `options` can be either a
207
208
string (a preset) or an object for more granular control:
208
209
209
210
``` js-with-links
210
- stats.toJson(" minimal" ); // [more options: " verbose" , etc](/configuration/stats).
211
+ stats.toJson(' minimal' ); // [more options: ' verbose' , etc](/configuration/stats).
211
212
```
212
213
213
214
``` js
@@ -241,7 +242,7 @@ stats.toString({
241
242
Here’s an example of ` stats.toString() ` usage:
242
243
243
244
``` js-with-links
244
- const webpack = require(" webpack" );
245
+ const webpack = require(' webpack' );
245
246
246
247
webpack({
247
248
// [Configuration Object](/configuration/)
@@ -273,7 +274,7 @@ webpack([
273
274
{ entry: './index1.js', output: { filename: 'bundle1.js' } },
274
275
{ entry: './index2.js', output: { filename: 'bundle2.js' } }
275
276
], (err, [stats](#stats-object)) => {
276
- process.stdout.write(stats.toString() + "\n" );
277
+ process.stdout.write(stats.toString() + '\n' );
277
278
})
278
279
```
279
280
@@ -294,7 +295,7 @@ For a good error handling, you need to account for these three types of errors:
294
295
Here’s an example that does all that:
295
296
296
297
``` js-with-links
297
- const webpack = require(" webpack" );
298
+ const webpack = require(' webpack' );
298
299
299
300
webpack({
300
301
// [Configuration Object](/configuration/)
@@ -337,7 +338,7 @@ const MemoryFS = require('memory-fs');
337
338
const webpack = require (' webpack' );
338
339
339
340
const fs = new MemoryFS ();
340
- const compiler = webpack ({ /* options*/ });
341
+ const compiler = webpack ({ /* options */ });
341
342
342
343
compiler .outputFileSystem = fs;
343
344
compiler .run ((err , stats ) => {
0 commit comments