@nx/vite
Version:
46 lines (45 loc) • 2.73 kB
TypeScript
import { TargetConfiguration, Tree } from '@nx/devkit';
import { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';
import { VitestGeneratorSchema } from '../generators/vitest/schema';
export type Target = 'build' | 'serve' | 'test' | 'preview';
export type TargetFlags = Partial<Record<Target, boolean>>;
export type UserProvidedTargetName = Partial<Record<Target, string>>;
export type ValidFoundTargetName = Partial<Record<Target, string>>;
export declare function findExistingJsBuildTargetInProject(targets: {
[targetName: string]: TargetConfiguration;
}): {
supported?: string;
unsupported?: string;
};
export declare function addOrChangeTestTarget(tree: Tree, options: VitestGeneratorSchema, hasPlugin: boolean): void;
export declare function addBuildTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, target: string): void;
export declare function addServeTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, target: string): void;
/**
* Adds a target for the preview server.
*
* @param tree
* @param options
* @param serveTarget An existing serve target.
*/
export declare function addPreviewTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, serveTarget: string): void;
export declare function editTsConfig(tree: Tree, options: ViteConfigurationGeneratorSchema): void;
export declare function deleteWebpackConfig(tree: Tree, projectRoot: string, webpackConfigFilePath?: string): void;
export declare function moveAndEditIndexHtml(tree: Tree, options: ViteConfigurationGeneratorSchema): void;
export interface ViteConfigFileOptions {
project: string;
includeLib?: boolean;
includeVitest?: boolean;
inSourceTests?: boolean;
testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;
rollupOptionsExternal?: string[];
imports?: string[];
plugins?: string[];
coverageProvider?: 'v8' | 'istanbul' | 'custom';
setupFile?: string;
useEsmExtension?: boolean;
}
export declare function createOrEditViteConfig(tree: Tree, options: ViteConfigFileOptions, onlyVitest: boolean, projectAlreadyHasViteTargets?: TargetFlags, vitestFileName?: boolean): void;
export declare function normalizeViteConfigFilePathWithTree(tree: Tree, projectRoot: string, configFile?: string): string;
export declare function getViteConfigPathForProject(tree: Tree, projectName: string, target?: string): string;
export declare function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported: TargetFlags, userProvidedTargetName: UserProvidedTargetName, validFoundTargetName: ValidFoundTargetName): Promise<void>;
export declare function handleUnknownConfiguration(projectName: string): Promise<void>;