From 00c6843bf53db65b002456c61afbc77bfe7cbbb2 Mon Sep 17 00:00:00 2001 From: Tucker Cowie Date: Wed, 14 Dec 2016 14:28:11 -0600 Subject: [PATCH 1/4] Add inlineManifest option --- lib/ChunkManifestPlugin.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ChunkManifestPlugin.js b/lib/ChunkManifestPlugin.js index d60164b..7604f02 100644 --- a/lib/ChunkManifestPlugin.js +++ b/lib/ChunkManifestPlugin.js @@ -4,6 +4,7 @@ function ChunkManifestPlugin(options) { options = options || {}; this.manifestFilename = options.filename || "manifest.json"; this.manifestVariable = options.manifestVariable || "webpackManifest"; + this.inlineManifest = options.inlineManifest || false; } module.exports = ChunkManifestPlugin; @@ -11,6 +12,7 @@ ChunkManifestPlugin.prototype.constructor = ChunkManifestPlugin; ChunkManifestPlugin.prototype.apply = function(compiler) { var manifestFilename = this.manifestFilename; var manifestVariable = this.manifestVariable; + var inlineManifest = this.inlineManifest; var oldChunkFilename; compiler.plugin("this-compilation", function(compilation) { @@ -52,5 +54,8 @@ ChunkManifestPlugin.prototype.apply = function(compiler) { return _.replace("\"__CHUNK_MANIFEST__\"", "window[\"" + manifestVariable + "\"][" + chunkIdVar + "]"); }); + + if (inlineManifest){ + } }); }; From 268c874f65ad7f2658e1985c23f8f2d9c80a6423 Mon Sep 17 00:00:00 2001 From: Tucker Cowie Date: Wed, 14 Dec 2016 14:28:37 -0600 Subject: [PATCH 2/4] Rescope chunkManifest var --- lib/ChunkManifestPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ChunkManifestPlugin.js b/lib/ChunkManifestPlugin.js index 7604f02..4ab733e 100644 --- a/lib/ChunkManifestPlugin.js +++ b/lib/ChunkManifestPlugin.js @@ -14,12 +14,12 @@ ChunkManifestPlugin.prototype.apply = function(compiler) { var manifestVariable = this.manifestVariable; var inlineManifest = this.inlineManifest; var oldChunkFilename; + var chunkManifest; compiler.plugin("this-compilation", function(compilation) { var mainTemplate = compilation.mainTemplate; mainTemplate.plugin("require-ensure", function(_, chunk, hash) { var filename = this.outputOptions.chunkFilename || this.outputOptions.filename; - var chunkManifest; if (filename) { chunkManifest = [chunk].reduce(function registerChunk(manifest, c) { From f8b69b8d3507ae9a11444b5743a3849e0b29be59 Mon Sep 17 00:00:00 2001 From: Tucker Cowie Date: Wed, 14 Dec 2016 14:29:30 -0600 Subject: [PATCH 3/4] Add chunkManifest to html-webpack-plugin data --- lib/ChunkManifestPlugin.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ChunkManifestPlugin.js b/lib/ChunkManifestPlugin.js index 4ab733e..46d85ed 100644 --- a/lib/ChunkManifestPlugin.js +++ b/lib/ChunkManifestPlugin.js @@ -56,6 +56,10 @@ ChunkManifestPlugin.prototype.apply = function(compiler) { }); if (inlineManifest){ + compilation.plugin("html-webpack-plugin-before-html-generation", function (data, callback) { + var manifestHtml = ""; + callback(null, data.assets[manifestVariable] = manifestHtml); + }); } }); }; From f19f91184f3a8bf7d8230519daf9709966ea4bd7 Mon Sep 17 00:00:00 2001 From: Tucker Cowie Date: Wed, 14 Dec 2016 14:38:31 -0600 Subject: [PATCH 4/4] Add options.inlineManifest documentation --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d79bd9e..b632e3c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ module.exports = { plugins: [ new ChunkManifestPlugin({ filename: "manifest.json", - manifestVariable: "webpackManifest" + manifestVariable: "webpackManifest", + inlineManifest: false }) ] }; @@ -42,3 +43,15 @@ Where the manifest will be exported to on bundle compilation. This will be relat #### `manifestVariable` What JS variable on the client webpack should refer to when requiring chunks. Default = `"webpackManifest"` + +#### `inlineManifest` + +Whether or not to write the manifest output into the [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin). Default = `false` + +```html +// index.ejs + + + <%= htmlWebpackPlugin.files.webpackManifest %> + +``` \ No newline at end of file