Adding format option for Dll Plugin to get a formatted manifest json.

This commit is contained in:
Naveen Marella 2018-10-03 09:48:29 -06:00
parent 4c461e2e1f
commit 71f9230383
4 changed files with 17 additions and 1 deletions

View File

@ -13,6 +13,10 @@ export interface DllPluginOptions {
* If true, only entry points will be exposed
*/
entryOnly?: boolean;
/**
* If true, manifest json file(output) will be formatted
*/
format?: boolean;
/**
* Name of the exposed dll function (external name, use value of 'output.library')
*/

View File

@ -20,6 +20,10 @@ class DllPlugin {
constructor(options) {
validateOptions(schema, options, "Dll Plugin");
this.options = options;
if (!options.format) {
this.options.format = false;
}
}
apply(compiler) {

View File

@ -67,7 +67,11 @@ class LibManifestPlugin {
return obj;
}, Object.create(null))
};
const content = Buffer.from(JSON.stringify(manifest), "utf8");
// Apply formatting to content if format flag is true;
const manifestContent = this.options.format
? JSON.stringify(manifest, null, 2)
: JSON.stringify(manifest);
const content = Buffer.from(manifestContent, "utf8");
compiler.outputFileSystem.mkdirp(path.dirname(targetPath), err => {
if (err) return callback(err);
compiler.outputFileSystem.writeFile(

View File

@ -12,6 +12,10 @@
"description": "If true, only entry points will be exposed",
"type": "boolean"
},
"format": {
"description": "If true, manifest json file (output) will be formatted",
"type": "boolean"
},
"name": {
"description": "Name of the exposed dll function (external name, use value of 'output.library')",
"type": "string",