From 1a1756d5380af82eb55626b507433f950e1571bc Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Thu, 2 Dec 2021 10:53:36 +0100 Subject: [PATCH] Add minify option to backend:build Co-authored-by: Ainhoa Larumbe Signed-off-by: Vincenzo Scamporlino --- .changeset/pretty-eagles-relate.md | 3 ++- docs/local-dev/cli-commands.md | 1 + packages/cli/src/commands/backend/build.ts | 4 +++- packages/cli/src/commands/index.ts | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.changeset/pretty-eagles-relate.md b/.changeset/pretty-eagles-relate.md index f9183aff9a..9e17be05d3 100644 --- a/.changeset/pretty-eagles-relate.md +++ b/.changeset/pretty-eagles-relate.md @@ -2,8 +2,9 @@ '@backstage/cli': patch --- -Add cli option to minify the generated code of a plugin +Add cli option to minify the generated code of a plugin or backend package ``` backstage-cli plugin:build --minify +backstage-cli backend:build --minify ``` diff --git a/docs/local-dev/cli-commands.md b/docs/local-dev/cli-commands.md index 9f107c1f83..318b37f34e 100644 --- a/docs/local-dev/cli-commands.md +++ b/docs/local-dev/cli-commands.md @@ -165,6 +165,7 @@ common example being the `migrations` directory. Usage: backstage-cli backend:build [options] Options: + --minify Minify the generated code -h, --help display help for command ``` diff --git a/packages/cli/src/commands/backend/build.ts b/packages/cli/src/commands/backend/build.ts index 6cb1347b1e..8c25f56746 100644 --- a/packages/cli/src/commands/backend/build.ts +++ b/packages/cli/src/commands/backend/build.ts @@ -14,10 +14,12 @@ * limitations under the License. */ +import { Command } from 'commander'; import { buildPackage, Output } from '../../lib/builder'; -export default async () => { +export default async (cmd: Command) => { await buildPackage({ outputs: new Set([Output.cjs, Output.types]), + minify: cmd.minify, }); }; diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index accc36239e..152d6efceb 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -44,6 +44,7 @@ export function registerCommands(program: CommanderStatic) { program .command('backend:build') .description('Build a backend plugin') + .option('--minify', 'Minify the generated code') .action(lazy(() => import('./backend/build').then(m => m.default))); program