You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugins grant unlimited opportunity to perform customizations within the webpack build system. This allows you to create custom asset types, perform unique build modifications, or even enhance the webpack runtime while using middleware. The following are some features of webpack that become useful while writing plugins.
@@ -10,63 +12,66 @@ Plugins grant unlimited opportunity to perform customizations within the webpack
10
12
After a compilation is sealed, all structures within the compilation may be traversed.
// we've learned a lot about the source structure now...
25
+
});
25
26
});
26
-
});
27
27
28
-
// Explore each asset filename generated by the chunk:
29
-
chunk.files.forEach(function(filename) {
30
-
// Get the asset source for each file generated by the chunk:
31
-
var source =compilation.assets[filename].source();
28
+
// Explore each asset filename generated by the chunk:
29
+
chunk.files.forEach(function(filename) {
30
+
// Get the asset source for each file generated by the chunk:
31
+
var source =compilation.assets[filename].source();
32
+
});
32
33
});
33
-
});
34
-
35
-
callback();
36
-
});
37
-
};
38
34
35
+
callback();
36
+
});
37
+
}
38
+
}
39
39
module.exports= MyPlugin;
40
40
```
41
41
42
-
-`compilation.modules`: An array of modules (built inputs) in the compilation. Each module manages the build of a raw file from your source library.
43
-
-`module.fileDependencies`: An array of source file paths included into a module. This includes the source JavaScript file itself (ex: `index.js`), and all dependency asset files (stylesheets, images, etc) that it has required. Reviewing dependencies is useful for seeing what source files belong to a module.
44
-
-`compilation.chunks`: An array of chunks (build outputs) in the compilation. Each chunk manages the composition of a final rendered assets.
45
-
-`chunk.modules`: An array of modules that are included into a chunk. By extension, you may look through each module's dependencies to see what raw source files fed into a chunk.
46
-
-`chunk.files`: An array of output filenames generated by the chunk. You may access these asset sources from the `compilation.assets` table.
42
+
*`compilation.modules`: An array of modules (built inputs) in the compilation. Each module manages the build of a raw file from your source library.
43
+
*`module.fileDependencies`: An array of source file paths included into a module. This includes the source JavaScript file itself (ex: `index.js`), and all dependency asset files (stylesheets, images, etc) that it has required. Reviewing dependencies is useful for seeing what source files belong to a module.
44
+
*`compilation.chunks`: An array of chunks (build outputs) in the compilation. Each chunk manages the composition of a final rendered assets.
45
+
*`chunk.modules`: An array of modules that are included into a chunk. By extension, you may look through each module's dependencies to see what raw source files fed into a chunk.
46
+
*`chunk.files`: An array of output filenames generated by the chunk. You may access these asset sources from the `compilation.assets` table.
47
47
48
48
### Monitoring the watch graph
49
49
50
50
While running webpack middleware, each compilation includes a `fileDependencies` array (what files are being watched) and a `fileTimestamps` hash that maps watched file paths to a timestamp. These are extremely useful for detecting what files have changed within the compilation:
0 commit comments