Skip to content

Commit

Permalink
fix(nx-plugin): add support for nx tsconfig paths for vitest setup (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzabuzaid authored and brandonroberts committed Apr 25, 2024
1 parent a2892d7 commit efe3712
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
@@ -1,12 +1,20 @@
/// <reference types="vitest" />

import angular from '@analogjs/vite-plugin-angular';
<% if (addNxPaths) { %>
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
<% } %>
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
plugins: [angular()],
plugins: [
angular(),
<% if (addNxPaths) { %>
nxViteTsPaths()
<% } %>
],
test: {
globals: true,
environment: 'jsdom',
Expand Down
4 changes: 3 additions & 1 deletion packages/nx-plugin/src/generators/setup-vitest/generator.ts
Expand Up @@ -9,17 +9,19 @@ import { join } from 'node:path';

import { getInstalledPackageVersion } from '../../utils/version-utils';
import { addAnalogDependencies } from './lib/add-analog-dependencies';
import { updateTsConfig } from './lib/update-tsconfig';
import { updateTestTarget } from './lib/update-test-target';
import { updateTsConfig } from './lib/update-tsconfig';
import { SetupVitestGeneratorSchema } from './schema';

function addFiles(tree: Tree, options: SetupVitestGeneratorSchema) {
const projects = getProjects(tree);
const isNx = tree.exists('/nx.json');

const projectConfig = projects.get(options.project);

const templateOptions = {
...options,
addNxPaths: isNx,
template: '',
};

Expand Down

0 comments on commit efe3712

Please sign in to comment.