Replies: 2 comments 2 replies
-
It seems like Heft doesn't have direct support for PostCSS but you may be able to use it (and by extension Tailwind) through Webpack. As an aside:
|
Beta Was this translation helpful? Give feedback.
-
This is a common issue when migrating from Gulp-based SPFx builds to Heft. The problem is that @microsoft/sp-css-loader doesn't understand PostCSS syntax like @import and @tailwind directives. Here are several solutions to get TailwindCSS working with SPFx + Heft: Solution 1: Pre-compile Tailwind CSS (Recommended) 1. Install dependencies:
2. Create a build script (build-tailwind.js):
3. Add to package.json scripts:json
4. Update your import:In your webpart: typescript |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am currently trying out version 1.22 of SharePoint Framework (SPFx), where Gulp has been replaced by Heft.
This has changed the method I use to add TailwindCSS, and that's where I'm having problems.
With Gulp, I always used TailwindCSS 3 and installed the following dependencies:
npm i autoprefixer gulp-postcss postcss [email protected] esbuild-loader
The CSS file was stored under
/src/webparts/ProjectName/assets/
However, in order to integrate Tailwind into the build process, I had to add the following to gulpfile.js:
I am now trying to use TailwindCSS 4 with PostCSS in the SPFx webpart, but I am having problems importing the Tailwind CSS file.
I have installed the following dependencies:
npm i autoprefixer postcss tailwindcss @tailwindcss/postcss esbuild-loader
postcss.config.mjs
tailwind.config,js
When I import the CSS file into the webpart, I get this error message:
Has anyone gotten TailwindCSS to work with Heft or found any workaround?
Beta Was this translation helpful? Give feedback.
All reactions