Skip to content

Commit

Permalink
feat(vite): add nodes - small additiongs
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Nov 7, 2023
1 parent 76b19ba commit 666782d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/vite/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import { getRootTsConfigPath } from '@nx/js';
import { readTargetDefaultsForTarget } from 'nx/src/project-graph/utils/project-configuration-utils';
import { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';
import { readdirSync } from 'fs';
import { ExecutorOptions } from '@nx/js/src/utils/schema';

export interface VitePluginOptions {
targetName?: string;
}

export const createNodes: CreateNodes<VitePluginOptions> = [
'**/TODO',
'**/vite.config.{js,ts}',
(configFilePath, options, context) => {
const projectRoot = dirname(configFilePath);

Expand Down Expand Up @@ -57,19 +58,19 @@ function buildViteTargets(
context: CreateNodesContext
) {
const viteConfig = getViteConfig(configFilePath, context);

console.log('Here is your viteConfig', viteConfig);
const targetDefaults = readTargetDefaultsForTarget(
options.targetName,
context.nxJsonConfiguration.targetDefaults,
'executorName'
'@nx/vite:build'
);

const namedInputs = getNamedInputs(projectRoot, context);

const targets: Record<string, TargetConfiguration<ExecutorOptions>> = {};

const baseTargetConfig: TargetConfiguration<ExecutorOptions> = {
executor: 'executorName',
executor: '@nx/vite:build',
options: {
config: configFilePath,
...targetDefaults?.options,
Expand Down Expand Up @@ -134,6 +135,6 @@ function getOutputs(projectRoot: string): string[] {

function normalizeOptions(options: VitePluginOptions): VitePluginOptions {
options ??= {};
options.targetName ??= 'TODO';
options.targetName ??= 'build';
return options;
}

0 comments on commit 666782d

Please sign in to comment.