UNPKG

@ikamva/ngx-tailwindcss

Version:

Tailwind CSS angular schematic

41 lines 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addTailwindCSSStyles = void 0; const config_1 = require("@schematics/angular/utility/config"); const style_file_1 = require("../../util/style-file"); const schematics_1 = require("@angular/cdk/schematics"); /** * Adds custom Tailwind CSS styles to the project style file. */ function addTailwindCSSStyles(options) { return (host, context) => { const workspace = config_1.getWorkspace(host); const project = schematics_1.getProjectFromWorkspace(workspace, options.project); const styleFilePath = style_file_1.getProjectStyleFile(project); const logger = context.logger; if (!styleFilePath) { logger.error(`Could not find the default style file for this project.`); return; } const buffer = host.read(styleFilePath); if (!buffer) { logger.error(`Could not read the default style file within the project ` + `(${styleFilePath})`); // logger.info(`Please consider manually setting up the Robot font.`); return; } const htmlContent = buffer.toString(); const insertion = "\n" + `@import 'tailwindcss/base';\n` + `@import 'tailwindcss/components';\n` + `@import 'tailwindcss/utilities';\n`; if (htmlContent.includes(insertion)) { return; } const recorder = host.beginUpdate(styleFilePath); recorder.insertLeft(htmlContent.length, insertion); host.commitUpdate(recorder); }; } exports.addTailwindCSSStyles = addTailwindCSSStyles; //# sourceMappingURL=addTailwindCSSStyles.js.map