frontity
Version:
Frontity cli and entry point to other packages
30 lines (29 loc) • 1.26 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const build_1 = __importDefault(require("../commands/build"));
const utils_1 = require("../utils");
/**
* The build CLI command, usually run with `npx frontity build`.
*
* It takes args from the CLI and checks for the presence of environment
* variables. Then, it runs the build command programatically.
*
* @param options - Defined in {@link BuildOptions}.
*/
const build = async ({ target = process.env.FRONTITY_BUILD_TARGET || "both", development = !!process.env.FRONTITY_BUILD_DEVELOPMENT, publicPath = process.env.FRONTITY_BUILD_PUBLIC_PATH || "/static/", analyze = !!process.env.FRONTITY_BUILD_ANALYZE, }) => {
// Check `target` parameter.
if (target && target !== "es5" && target !== "module" && target !== "both") {
utils_1.errorLogger(new Error(`The target specified is invalid: "${target}". Use either "module", "es5" or "both".`));
}
// Execute the `build` command.
build_1.default({
target: target,
development,
publicPath,
analyze,
});
};
exports.default = build;