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

42 lines (41 loc) 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createGlobPatternsForDependencies = createGlobPatternsForDependencies; const generate_globs_1 = require("@nx/js/src/utils/generate-globs"); const path_1 = require("path"); /** * Generates a set of glob patterns based off the source root of the app and its dependencies * @param dirPath workspace relative directory path that will be used to infer the parent project and dependencies * @param fileGlobPatternToInclude pass a custom glob pattern to be used * @param fileGlobPatternToExclude pass a custom glob pattern for files to be excluded */ function createGlobPatternsForDependencies(dirPath, fileGlobPatternToInclude = '/**/*.{tsx,ts,jsx,js,html}', fileGlobPatternToExclude = '/**/*.{stories,spec}.{tsx,ts,jsx,js,html}') { /** * There is an issue with TailwindCSS v4 and how globs patterns are consumed. * This is a temporary workaround to support both TailwindCSS v4 and v3. * Once TailwindCSS v3 is no longer supported, this workaround can be removed. */ const tailwindVersion = require(require.resolve('tailwindcss/package.json', { paths: [dirPath], })).version; if (tailwindVersion && typeof tailwindVersion === 'string') { const majorVersion = parseInt(tailwindVersion.split('.')[0], 10); if (majorVersion >= 4) { try { return [ ...(0, generate_globs_1.createGlobPatternsForDependencies)(dirPath, fileGlobPatternToInclude).map((glob) => (0, path_1.relative)(dirPath, glob)), ...(0, generate_globs_1.createGlobPatternsForDependencies)(dirPath, fileGlobPatternToExclude).map((glob) => `!${(0, path_1.relative)(dirPath, glob)}`), ]; } catch (e) { console.warn('\nWARNING: There was an error creating glob patterns, returning an empty array\n' + `${e.message}\n`); } } else { const { createGlobPatternsForDependencies: reactGlobPatternFunction, } = require('@nx/react/tailwind'); return reactGlobPatternFunction(dirPath, fileGlobPatternToInclude); } } return []; }