I did a fresh install composer create-project roots/sage your-theme-name of sage today for the first time. I ran yarn && yarn build build immediately after it finished and it fails. If I goto that file in vscode and hover over tailwind I get this error, Unknown at rule @tailwindscss(unknownAtRules). What am I doing wrong?
Sage vesion: 9.0.10
Yarn version: 1.22.10
Node version: 15.6.0 (although I went back to 14 to try again and it’s the same failure)
Composer version: 2.0.8
PHP version: 7.3.24
ERROR Failed to compile with 2 errors 7:39:27 PM
error in ./resources/assets/styles/main.scss
Module build failed: ModuleBuildError: Module build failed: ValidationError: Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options has an unknown property 'plugins'. These properties are valid:
object { postcssOptions?, execute?, sourceMap? }
at validate (/Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/schema-utils/dist/validate.js:104:11)
at Object.loader (/Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/postcss-loader/dist/index.js:43:29)
at /Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/webpack/lib/NormalModule.js:195:19
at /Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/loader-runner/lib/LoaderRunner.js:367:11
at /Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/loader-runner/lib/LoaderRunner.js:233:18
@ multi ./scripts/main.js ./styles/main.scss
error in ./resources/assets/styles/main.scss
Module build failed: ModuleBuildError: Module build failed: ValidationError: Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
- options has an unknown property 'plugins'. These properties are valid:
object { postcssOptions?, execute?, sourceMap? }
at validate (/Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/schema-utils/dist/validate.js:104:11)
at Object.loader (/Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/postcss-loader/dist/index.js:43:29)
at /Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/webpack/lib/NormalModule.js:195:19
at /Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/loader-runner/lib/LoaderRunner.js:367:11
at /Users/chromebook/pantheon/ashmore/wp-content/themes/ashmore/node_modules/loader-runner/lib/LoaderRunner.js:233:18
Thanks Josh – I did a search but didnt’ find anything conclusive. I’ll take a look at this in the AM and see if I can get it running. At a quick glance it seems like this is a bug with Sage’s create-project scripts. Not the best first experience with Sage. =)
I wouldn’t use Sage 9 with Tailwind. I tried it and it was quite cumbersome, so I went the Sage 10 route and it was butter smooth with laravel mix. And really, Sage 10 isn’t released yet officially, but I find it better mantained than Sage 9 that was starting to have a lot of problems IMHO.
Thanks again @joshb for the direct way to get up and running in 9.
@SergiArias (or anyone), when running composer create-project roots/sage your-theme-name dev-master none of the CLI questions get asked, I assume the presents are not done. Has someone outlined how to move to Tailwind with dev-master after initializing a new theme? I’ll start by removing the bootstrap dep in package.json and installing tailwind and see what fails. Web dev at it’s finest!
Since I am new, anything would help as I am still getting used to the folder structures in Sage. All in all though, this is a heck of a lot better than WordPress theming of yesterday.
Quick follow up of steps I am following this morning…
Remove boostrap from package.json
Yarn install yarn add -D tailwindcss@npm:@tailwindcss/postcss7-compat @tailwindcss/postcss7-compat postcss@^7 via their docs but noting that autoprefixer is already there.
npx tailwindcss init
… read more documentation/threads here to see if I can find more steps. I will update this comment as I go.
… I imagine others have already gone through this setup so please feel free to share your experiences.
As already pointed out by @joshb I already gone through the whole steps, it took a bunch of days to get a working setup
If you want to bypass all the hassle you can clone my fork on branch 9-webpack5-tailwind2 and start from there (as said by @joshb), it’s the same result you’ll be getting with create-project.
If you want to use SCSS you only need to rename the CSS files to _filename.scss and update main.scss accordingly, webpack should already be ready for that (but as I pointed out SCSS is no more needed, at least for me).
@ciromattia My mistake, I thought that branch mentioned above was for Sage 9? I am looking to do this in Sage 10. I did find staged, and I see @Log1xrecently added this PR I can follow… Part of me is holding my breath that this will be merged in within the next few days.
It’s important that you remove purgeCss as tailwind has its own setup of it, and if you keep it like so, you won’t be able to ignore styles inside the scss files (quite useful for styles defined for menus or inside the wordpress database).
From there you just have to clean a little the scss files as they are customized with bootstrap.
I hope they ditch bootstrap soon too. It was the best framework for a long time, but now it just got old by the brilliant approach from Tailwind.