diff --git a/packages/cli/src/commands/plugin/export.ts b/packages/cli/src/commands/plugin/export.ts new file mode 100644 index 0000000000..b6db0d8ddd --- /dev/null +++ b/packages/cli/src/commands/plugin/export.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Command } from 'commander'; +import { loadConfig } from '@backstage/config-loader'; +import { ConfigReader } from '@backstage/config'; +import { buildBundle } from '../../lib/bundler'; + +export default async (cmd: Command) => { + const appConfigs = await loadConfig(); + await buildBundle({ + entry: 'dev/index', + statsJsonEnabled: cmd.stats, + config: ConfigReader.fromConfigs(appConfigs), + appConfigs, + }); +}; diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 9a102ab7d3..7521549d96 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -103,6 +103,12 @@ const main = (argv: string[]) => { .option('--check', 'Enable type checking and linting') .action(lazyAction(() => import('./commands/plugin/serve'), 'default')); + program + .command('plugin:export') + .description('Exports the dev/ folder of a plugin') + .option('--stats', 'Write bundle stats to output directory') + .action(lazyAction(() => import('./commands/plugin/export'), 'default')); + program .command('plugin:diff') .option('--check', 'Fail if changes are required')