UNPKG

@nx/next

Version:

The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides: - Scaffolding for creating, building, serving, linting, and testing Next.js applications. - Integration wit

37 lines (36 loc) 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.componentGenerator = componentGenerator; const internal_1 = require("@nx/devkit/internal"); const devkit_1 = require("@nx/devkit"); const react_1 = require("@nx/react"); const styles_1 = require("../../utils/styles"); const assert_supported_next_version_1 = require("../../utils/assert-supported-next-version"); /* * This schematic is basically the React one, but for Next we need * extra dependencies for css, sass, less style options. */ async function componentGenerator(host, options) { (0, assert_supported_next_version_1.assertSupportedNextVersion)(host); // we only need to provide the path to get the project, we let the react // generator handle the rest const { project: projectName } = await (0, internal_1.determineArtifactNameAndDirectoryOptions)(host, { path: options.path, }); const componentInstall = await (0, react_1.componentGenerator)(host, { ...options, classComponent: false, routing: false, skipFormat: true, }); const project = (0, devkit_1.readProjectConfiguration)(host, projectName); const styledInstall = (0, styles_1.addStyleDependencies)(host, { style: options.style, swc: !host.exists((0, devkit_1.joinPathFragments)(project.root, '.babelrc')), }); if (!options.skipFormat) { await (0, devkit_1.formatFiles)(host); } return (0, devkit_1.runTasksInSerial)(styledInstall, componentInstall); } exports.default = componentGenerator;