UNPKG

900 BPlain TextView Raw
1import * as program from 'commander';
2import * as path from 'path';
3import * as shell from 'shelljs';
4import { Component } from './component';
5import { exit, isNutmegComponent, notifyOfUpdate, nutmegDir, tsconfigPath } from './utils';
6
7notifyOfUpdate();
8
9program.command('build <path>', 'compile a Web Component')
10 .parse(process.argv);
11
12const workingDir = path.resolve(process.cwd(), program.args[0]);
13const webpackConfigFile = path.resolve(nutmegDir, 'webpack.component.config.js');
14const tag = Component.tagFromPackage(workingDir);
15const tscCmd = `tsc --project ${tsconfigPath(workingDir)} --watch`;
16const webpackCmd = `webpack-dev-server --config ${webpackConfigFile} --env.tag=${tag} --env.workingDir=${workingDir} --open`;
17
18exit("Directory doesn't have a package.json with @nutmeg/seed as a dependancy.", !isNutmegComponent(workingDir));
19
20shell.exec(`npx ${tscCmd} & npx ${webpackCmd}`);