Heya I have a issue with tailwind on preview/production. I am compiling tailwind on the api, it works fine on my local environment, but on preview and I am assuming production. I get this error "ENOENT: no such file or directory, open '/var/task/node_modules/tailwindcss/lib/css/preflight.css'"
Current versus Expected behavior
I except my tailwind styles to generated from the provided classes.
However I receive this error "ENOENT: no such file or directory, open '/var/task/node_modules/tailwindcss/lib/css/preflight.css'"
Sorry to hear you’ve been seeing this issue. Could you share a minimal reproducible example with us? That would help us dig deeper on what you’re seeing exactly.
@pawlean any update on this, or maybe do you need me to provide a new minimal example?
I am also testing the idea of running a postinstall script to copy the correct files during the build process.
Something like "postinstall": "node ./utils/copy_assets.js"
//copy_assets.js
import { createReadStream, createWriteStream, existsSync, mkdirSync } from "fs";
import { basename, resolve } from "path";
const output_dir = "../../var/task/node_modules/tailwindcss/lib/css/"; // The directory where files will be copied.
const assets = [
"../../node_modules/tailwindcss/lib/css/preflight.css", // Adjusted path to reflect the new structure
];
if (process.env.VERCEL) {
assets.forEach((asset_path) => {
const filename = basename(asset_path); // Extract the filename from the path.
const outputPath = resolve(output_dir, filename); // Resolve the full output path.
// Create the output directory if it doesn't exist
if (!existsSync(output_dir)) {
mkdirSync(output_dir, { recursive: true });
}
// Copy the file from node_modules to the public directory
createReadStream(resolve(asset_path)).pipe(createWriteStream(outputPath));
});
}
But I am unsure where to place the file as I have a monorepo with a nitro server which compiles my tailwind styles.
Update doing this does not work still receiving the error "ENOENT: no such file or directory, open '/var/task/node_modules/tailwindcss/lib/css/preflight.css'"