@nx-plugins/vite
Version:
The Nx Plugin for Vite that contains executors, generators, and utilities for managing Vite applications and libraries within an Nx workspace.
27 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateBaseTsConfig = void 0;
const devkit_1 = require("@nrwl/devkit");
const typescript_1 = require("@nrwl/workspace/src/utilities/typescript");
function updateBaseTsConfig(host, options) {
(0, devkit_1.updateJson)(host, (0, typescript_1.getRootTsConfigPathInTree)(host), (json) => {
const c = json.compilerOptions;
c.paths = c.paths || {};
delete c.paths[options.name];
if (c.paths[options.importPath]) {
throw new Error(`You already have a library using the import path "${options.importPath}". Make sure to specify a unique one.`);
}
const { libsDir } = (0, devkit_1.getWorkspaceLayout)(host);
c.paths[options.importPath] = [
maybeJs(options, (0, devkit_1.joinPathFragments)(libsDir, `${options.projectDirectory}/src/index.ts`)),
];
return json;
});
}
exports.updateBaseTsConfig = updateBaseTsConfig;
function maybeJs(options, path) {
return options.js && (path.endsWith('.ts') || path.endsWith('.tsx'))
? path.replace(/\.tsx?$/, '.js')
: path;
}
//# sourceMappingURL=update-base-tsconfig.js.map