UNPKG

@morfeo/compiler

Version:

![Morfeo logo](https://morfeo.dev/img/morfeo.png)

57 lines 2.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const fs = tslib_1.__importStar(require("fs")); const path = tslib_1.__importStar(require("path")); const cosmiconfig_1 = require("cosmiconfig"); const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader"); const commander_1 = require("commander"); const collector_1 = require("./collector"); const logger_1 = require("./logger"); const moduleName = 'morfeo'; const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), { encoding: 'utf8', })); const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, { searchPlaces: [ `.${moduleName}rc.js`, `.${moduleName}rc.ts`, `.${moduleName}rc.cjs`, `${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.cjs`, ], loaders: { '.ts': (0, cosmiconfig_typescript_loader_1.TypeScriptLoader)(), }, }); const program = new commander_1.Command(); program .name('morfeo') .version(packageJson.version, '-v, --version') .description("Run the morfeo's CLI to extract CSS from your js/ts files") .option('-e, --entryPoints', 'Entry points where morfeo should search for styles to extract') .option('-c, --classNamePrefix', 'The prefix for each generated class') .option('-o, --output', 'The path of the file where the css will be stored') .option('-E, --emojis', 'Whether or not the minified classes should use emojis 😎') .option('-m, --minify', 'Whether or not the classes should be minified') .option('-w, --watch [boolean]', 'Indicated if morfeo should watch for file changes') .parse(process.argv); const configFromCli = program.opts(); function runMorfeo(config) { collector_1.collector.init(Object.assign(Object.assign({}, config), configFromCli)); collector_1.collector.collect(); } function onError() { logger_1.logger.warning('morfeo configuration file not found.'); runMorfeo(configFromCli); } function onFound(result) { if (!result) { return onError(); } logger_1.logger.success(`morfeo configuration file found at ${result.filepath}`); runMorfeo(result.config); } explorer.search().then(onFound).catch(onError); //# sourceMappingURL=cli.js.map