UNPKG

@nxext/stencil

Version:

Nx plugin for stenciljs

57 lines 3.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.initializeStencilConfig = initializeStencilConfig; const tslib_1 = require("tslib"); const node_1 = require("@stencil/core/sys/node"); const compiler_1 = require("@stencil/core/compiler"); const path_1 = require("path"); const normalize_path_1 = require("../../utils/normalize-path"); function getCompilerExecutingPath() { return require.resolve('@stencil/core/compiler'); } function initializeStencilConfig(taskCommand, options, context, flags) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b, _c; const logger = (0, node_1.createNodeLogger)({ process }); const sys = (0, node_1.createNodeSys)({ process }); if (sys.getCompilerExecutingPath == null) { sys.getCompilerExecutingPath = getCompilerExecutingPath; } if (flags.ci) { logger.enableColors(false); } const projectDir = context.projectsConfigurations.projects[context.projectName].root; const projectRoot = (0, normalize_path_1.normalizePath)((0, path_1.join)(context.root, projectDir)); const distDir = (0, normalize_path_1.normalizePath)((0, path_1.join)(context.root, options.outputPath)); const configPath = (0, normalize_path_1.normalizePath)((0, path_1.join)(context.root, options.configPath)); let config = { flags, }; if (options.tsConfig) { const tsconfig = (0, path_1.join)(context.root, options.tsConfig); config = Object.assign(Object.assign({}, config), { tsconfig: tsconfig }); } const loadConfigResults = yield (0, compiler_1.loadConfig)({ config, configPath, logger, sys, }); const loadedConfig = loadConfigResults.config; const strictConfig = Object.assign(Object.assign({}, loadedConfig), { flags: flags, logger, outputTargets: (_a = loadedConfig === null || loadedConfig === void 0 ? void 0 : loadedConfig.outputTargets) !== null && _a !== void 0 ? _a : [], rootDir: (_b = loadedConfig === null || loadedConfig === void 0 ? void 0 : loadedConfig.rootDir) !== null && _b !== void 0 ? _b : '/', sys: sys !== null && sys !== void 0 ? sys : loadedConfig === null || loadedConfig === void 0 ? void 0 : loadedConfig.sys, testing: (_c = loadedConfig === null || loadedConfig === void 0 ? void 0 : loadedConfig.testing) !== null && _c !== void 0 ? _c : {} }); if (strictConfig.flags.task === 'build') { strictConfig.rootDir = distDir; strictConfig.packageJsonFilePath = (0, normalize_path_1.normalizePath)((0, path_1.join)(distDir, 'package.json')); } return { pathCollection: { projectName: context.projectName, projectRoot: projectRoot, distDir: distDir, pkgJson: (0, path_1.join)(projectRoot, 'package.json'), }, strictConfig: strictConfig, }; }); } //# sourceMappingURL=stencil-config.js.map