UNPKG

@procore/core-scripts

Version:

A CLI to enhance your development experience

54 lines 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const cli_highlight_1 = require("cli-highlight"); const webpack_1 = tslib_1.__importDefault(require("webpack")); const library_1 = require("../../webpack/library"); const BaseCommand_1 = require("../../BaseCommand"); class LibBuildCommand extends BaseCommand_1.BaseCommand { constructor() { super(...arguments); this.env = 'production'; this.handler = (error, stats) => { if (error) { this.error(error); } this.log(stats === null || stats === void 0 ? void 0 : stats.toString({ chunks: false, colors: true })); if (stats === null || stats === void 0 ? void 0 : stats.hasErrors()) { this.exit(1); } }; } async run() { // eslint-disable-next-line no-shadow const { flags } = this.parse(LibBuildCommand); const config = (0, library_1.createWebpackConfig)({ env: 'production', workspace: this.workspace, analyze: flags.analyze, }); if (flags.inspect) { // @ts-ignore Fix: type spec const output = config.toString({ verbose: false }); this.log((0, cli_highlight_1.highlight)(output, { language: 'js' })); this.exit(0); } const webpackConfig = config.toConfig(); const compiler = (0, webpack_1.default)(webpackConfig); compiler.run(this.handler); } } LibBuildCommand.description = 'Compiles the library in production mode.'; LibBuildCommand.flags = { analyze: command_1.flags.boolean({ default: false, description: 'Run webpack bundle analyzer.', }), inspect: command_1.flags.boolean({ default: false, description: 'Prints the Webpack configuration.', }), }; exports.default = LibBuildCommand; //# sourceMappingURL=build.js.map