UNPKG

@nx/rsbuild

Version:

The Nx Plugin for Rsbuild contains an Nx plugin, executors and utilities that support building applications using Rsbuild.

38 lines (37 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeOptions = normalizeOptions; const devkit_1 = require("@nx/devkit"); const path_1 = require("path"); async function normalizeOptions(tree, schema, project) { // Paths should be relative to the project root because inferred task will run from project root let options = { ...schema, target: schema.target ?? 'web', entry: normalizeRelativePath(schema.entry ?? './src/index.ts', project.root), tsConfig: normalizeRelativePath(schema.tsConfig ?? './tsconfig.json', project.root), devServerPort: schema.devServerPort ?? 4200, projectRoot: project.root, skipFormat: schema.skipFormat ?? false, skipValidation: schema.skipValidation ?? false, }; if (!schema.tsConfig) { const possibleTsConfigPaths = [ './tsconfig.app.json', './tsconfig.lib.json', './tsconfig.json', ]; const tsConfigPath = possibleTsConfigPaths.find((p) => tree.exists((0, devkit_1.joinPathFragments)(project.root, p))); options.tsConfig = tsConfigPath ?? undefined; } return options; } function normalizeRelativePath(filePath, projectRoot) { if (filePath.startsWith('./')) { return filePath; } filePath = filePath.startsWith(projectRoot) ? (0, path_1.relative)(projectRoot, filePath) : filePath; return `./${filePath}`; }