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

35 lines (34 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.componentGenerator = componentGenerator; const devkit_1 = require("@nx/devkit"); const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils"); const react_1 = require("@nx/react"); const styles_1 = require("../../utils/styles"); /* * 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) { // we only need to provide the path to get the project, we let the react // generator handle the rest const { project: projectName } = await (0, artifact_name_and_directory_utils_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;