Skip to content

Commit

Permalink
Create test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tmikaeld authored Nov 22, 2024
0 parents commit 98de91a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import postcss from "npm:postcss";
import tailwindcss from "npm:@tailwindcss/postcss@next";

const tailwindBaseConfig = {
content: [{ raw: '<div class="text-red-500"></div>', extension: "html" }],
corePlugins: { preflight: false },
};

async function generateCSS(tailwindConfig) {
try {
const tailwindDirectives = `
@tailwind components;
@tailwind utilities;
`;

console.log('Config:', JSON.stringify(tailwindConfig, null, 2));
console.log('Directives:', tailwindDirectives);

const result = await postcss([tailwindcss(tailwindConfig)])
.process(tailwindDirectives, { from: undefined });
return result.css;
} catch (error) {
console.error("Error generating CSS:", error);
throw error;
}
}

// Run the test
console.log('Starting CSS generation...');
const css = await generateCSS(tailwindBaseConfig);
console.log('\nFinal CSS:', Math.round(css.length/1000)+' KB');

0 comments on commit 98de91a

Please sign in to comment.