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

65 lines (64 loc) 2.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateDependencies = updateDependencies; exports.addVitestTargetDefaults = addVitestTargetDefaults; exports.addPlugin = addPlugin; const devkit_1 = require("@nx/devkit"); const versions_1 = require("../../../utils/versions"); function updateDependencies(host, schema) { return (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@nx/nuxt': versions_1.nxVersion, nuxt: versions_1.nuxtVersion, '@nx/vite': versions_1.nxVersion, }, undefined, schema.keepExistingVersions); } function addVitestTargetDefaults(tree) { const nxJson = (0, devkit_1.readNxJson)(tree); const productionFileSet = nxJson.namedInputs?.production; if (productionFileSet) { productionFileSet.push('!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)', '!{projectRoot}/tsconfig.spec.json'); nxJson.namedInputs.production = Array.from(new Set(productionFileSet)); } (0, devkit_1.updateNxJson)(tree, nxJson); } function addPlugin(tree) { const nxJson = (0, devkit_1.readNxJson)(tree); nxJson.plugins ??= []; let hasNxNuxtPlugin = false; let hasNxVitePlugin = false; for (const plugin of nxJson.plugins) { if (typeof plugin === 'string' ? plugin === '@nx/nuxt/plugin' : plugin.plugin === '@nx/nuxt/plugin') { hasNxNuxtPlugin = true; } if (typeof plugin === 'string' ? plugin === '@nx/vite/plugin' : plugin.plugin === '@nx/vite/plugin') { hasNxVitePlugin = true; } } if (!hasNxNuxtPlugin) { nxJson.plugins.push({ plugin: '@nx/nuxt/plugin', options: { buildTargetName: 'build', serveTargetName: 'serve', serveStaticTargetName: 'serve-static', }, }); } if (!hasNxVitePlugin) { nxJson.plugins.push({ plugin: '@nx/vite/plugin', options: { buildTargetName: 'build', previewTargetName: 'preview', testTargetName: 'test', serveTargetName: 'serve', serveStaticTargetName: 'serve-static', }, }); } (0, devkit_1.updateNxJson)(tree, nxJson); }