All files / src/plugin vitek.ts

100% Statements 4/4
66.66% Branches 2/3
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                      27x 27x 27x   27x                  
/**
 * Main Vitek plugin — aggregates sub-plugins
 */
 
import type { Plugin } from 'vite';
import { API_DIR_NAME } from '../shared/constants.js';
import { createPluginContext } from './context.js';
import { createConfigPlugin } from './vitek-config.js';
import { createBuildPlugin } from './vitek-build.js';
import { createResolvePlugin } from './vitek-resolve.js';
import { createTransformPlugin } from './vitek-transform.js';
import { createDevPlugin } from './vitek-dev.js';
import { createPreviewPlugin } from './vitek-preview.js';
import type { VitekOptions } from './options.js';
 
/**
 * Vite plugin for Vitek — returns array of sub-plugins.
 */
export function vitek(options: VitekOptions = {}): Plugin[] {
  const apiDirOption = options.apiDir || `src/${API_DIR_NAME}`;
  const buildApi = options.buildApi !== false;
  const ctx = createPluginContext(options, apiDirOption, buildApi);
 
  return [
    createConfigPlugin(ctx),
    createBuildPlugin(ctx),
    createResolvePlugin(ctx),
    createTransformPlugin(ctx),
    createDevPlugin(ctx),
    createPreviewPlugin(ctx),
  ];
}