@nx/react
Version:
28 lines (25 loc) • 1.38 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.addTailwindStyleImports = addTailwindStyleImports;
const devkit_1 = require("@nx/devkit");
// base directories and file types to simplify locating the stylesheet
const baseDirs = ['src', 'pages', 'src/pages', 'src/app', 'app'];
const fileNames = ['styles', 'global'];
const extensions = ['.css', '.scss', '.less'];
const knownLocations = baseDirs.flatMap((dir) => fileNames.flatMap((name) => extensions.map((ext) => `${dir}/${name}${ext}`)));
function addTailwindStyleImports(tree, project, _options) {
const candidates = knownLocations.map((currentPath) => (0, devkit_1.joinPathFragments)(project.root, currentPath));
const stylesPath = candidates.find((currentStylePath) => tree.exists(currentStylePath));
if (stylesPath) {
const content = tree.read(stylesPath).toString();
tree.write(stylesPath, `@tailwind base;\n@tailwind components;\n@tailwind utilities;\n${content}`);
}
else {
devkit_1.logger.warn((0, devkit_1.stripIndents) `
Could not find stylesheet to update. Add the following imports to your stylesheet (e.g. styles.css):
@tailwind base;
@tailwind components;
@tailwind utilities;
See our guide for more details: https://nx.dev/guides/using-tailwind-css-in-react`);
}
}
;