frigjord
frigjord2w ago

Tailwind V4 Beta 1

The same works in Tailwind V3, but here it produces 22KB of unrelated styles.
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 Size:', Math.round(css.length/1000)+' KB');
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 Size:', Math.round(css.length/1000)+' KB');
1 Reply