UNPKG

@nx/nuxt

Version:

The Nuxt plugin for Nx contains executors and generators for managing Nuxt applications and libraries within an Nx workspace. It provides: - Integration with libraries such as Vitest, Playwright, Cypress, and Storybook. - Generators for applications, l

39 lines (38 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addVitest = addVitest; const devkit_1 = require("@nx/devkit"); const utils_1 = require("../../init/lib/utils"); const versions_1 = require("../../../utils/versions"); async function addVitest(tree, options) { (0, utils_1.addVitestTargetDefaults)(tree); const nxJson = (0, devkit_1.readNxJson)(tree); const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string' ? p === '@nx/nuxt/plugin' : p.plugin === '@nx/nuxt/plugin'); const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion); const vitestTask = await vitestGenerator(tree, { project: options.projectName, uiFramework: 'none', coverageProvider: 'v8', skipFormat: true, testEnvironment: 'jsdom', skipViteConfig: true, addPlugin: true, }, hasPlugin); createOrEditViteConfig(tree, { project: options.projectName, includeLib: false, includeVitest: true, testEnvironment: 'jsdom', imports: [`import vue from '@vitejs/plugin-vue'`], plugins: ['vue()'], }, true, undefined, true); (0, devkit_1.updateJson)(tree, `${options.appProjectRoot}/tsconfig.spec.json`, (json) => { json.compilerOptions ??= {}; json.compilerOptions.composite = true; json.include = ['.nuxt/nuxt.d.ts', ...(json.include ?? [])]; return json; }); return vitestTask; }