@@ -4,20 +4,22 @@ function ChunkManifestPlugin(options) {
4
4
options = options || { } ;
5
5
this . manifestFilename = options . filename || "manifest.json" ;
6
6
this . manifestVariable = options . manifestVariable || "webpackManifest" ;
7
+ this . inlineManifest = options . inlineManifest || false ;
7
8
}
8
9
module . exports = ChunkManifestPlugin ;
9
10
10
11
ChunkManifestPlugin . prototype . constructor = ChunkManifestPlugin ;
11
12
ChunkManifestPlugin . prototype . apply = function ( compiler ) {
12
13
var manifestFilename = this . manifestFilename ;
13
14
var manifestVariable = this . manifestVariable ;
15
+ var inlineManifest = this . inlineManifest ;
14
16
var oldChunkFilename ;
17
+ var chunkManifest ;
15
18
16
19
compiler . plugin ( "this-compilation" , function ( compilation ) {
17
20
var mainTemplate = compilation . mainTemplate ;
18
21
mainTemplate . plugin ( "require-ensure" , function ( _ , chunk , hash ) {
19
22
var filename = this . outputOptions . chunkFilename || this . outputOptions . filename ;
20
- var chunkManifest ;
21
23
22
24
if ( filename ) {
23
25
chunkManifest = [ chunk ] . reduce ( function registerChunk ( manifest , c ) {
@@ -52,5 +54,12 @@ ChunkManifestPlugin.prototype.apply = function(compiler) {
52
54
return _ . replace ( "\"__CHUNK_MANIFEST__\"" ,
53
55
"window[\"" + manifestVariable + "\"][" + chunkIdVar + "]" ) ;
54
56
} ) ;
57
+
58
+ if ( inlineManifest ) {
59
+ compilation . plugin ( "html-webpack-plugin-before-html-generation" , function ( data , callback ) {
60
+ var manifestHtml = "<script>window." + manifestVariable + "=" + JSON . stringify ( chunkManifest ) + "</script>" ;
61
+ callback ( null , data . assets [ manifestVariable ] = manifestHtml ) ;
62
+ } ) ;
63
+ }
55
64
} ) ;
56
65
} ;
0 commit comments