From fd87394b145d5f690199cc46adfc451e27019f00 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 2 Feb 2018 01:51:32 -0500 Subject: [PATCH] feat: improve inspect output --- packages/@vue/cli-service/lib/commands/inspect.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli-service/lib/commands/inspect.js b/packages/@vue/cli-service/lib/commands/inspect.js index b6f1e897d2..6165f86cc8 100644 --- a/packages/@vue/cli-service/lib/commands/inspect.js +++ b/packages/@vue/cli-service/lib/commands/inspect.js @@ -25,7 +25,18 @@ module.exports = (api, options) => { res = config } - // TODO improve stringification for loaders, plugins etc. - console.log(stringify(res, null, 2)) + const pluginRE = /(?:function|class) (\w+Plugin)/ + console.log(stringify(res, (value, indent, stringify) => { + if (typeof value === 'function' && value.toString().length > 100) { + return `function () { /* omitted long function */ }` + } + if (value && typeof value.constructor === 'function') { + const match = value.constructor.toString().match(pluginRE) + if (match) { + return `/* ${match[1]} */ ` + stringify(value) + } + } + return stringify(value) + }, 2)) }) }