diff --git a/README.md b/README.md index 5600780..8bd3ace 100644 --- a/README.md +++ b/README.md @@ -60,13 +60,14 @@ createPlugins( which `inputPlugins` is among these: ``` +js (considered by default) ts babel coffee json css wasm -(js is considered by default) +visualizer ``` You can pass an input plugin with their supported option: diff --git a/package.json b/package.json index 0e4d056..eb66bc1 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "rollup-plugin-execute": "^1.1.1", "csso-cli": "^3.0.0", "array-includes-any": "^2.7.3", - "rollup-plugin-sourcemaps": "^0.6.3" + "rollup-plugin-sourcemaps": "^0.6.3", + "rollup-plugin-visualizer": "^4.1.1" }, "peerDependencies": { "rollup": "2.31.0", diff --git a/src/main.ts b/src/main.ts index 2f13173..790c7ca 100644 --- a/src/main.ts +++ b/src/main.ts @@ -170,6 +170,19 @@ export function createPlugins( } } + // visualizer + const visualizerIndex = includesAny(inputPluginsNames, ["visualizer", "plot"]) + if (visualizerIndex !== null) { + const visualizer = require("rollup-plugin-visualizer") + if (typeof inputPluginsNames[visualizerIndex] === "string") { + // plugin name only + plugins.push(visualizer({sourcemap: true, open: true})) + } else { + // plugin with options + plugins.push(visualizer(inputPluginsNames[visualizerIndex][1])) + } + } + // extra plugins if (typeof extraPlugins !== "boolean" && extraPlugins !== undefined) { try {