@nx/nuxt
Version:
65 lines (64 loc) • 2.34 kB
JavaScript
;
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);
}