Hi Everyone,
I have a weird problem with any fresh “Sage” project i start.
If i tried to add any “Plugins” in the plugins array i have that error when trying to compile assets “yarn build”
That happens only when “tailwind.config.js” has the extension “.js”, if i switched it to “.cjs” everything works.
I want to follow the sage’s procedure because they added the “tailwind.config” with “.js” extension.
Anyone have any idea how can i solve that?
Sage version: 10.6
Error:
[fs] [tailwind.config.js] › tailwind.config.js causes an exception when imported. Since tailwind.config.js does not appear to be a bud configuration file, bud.js is not throwing. Original error follows:
BudError: require is not defined in ES module scope, you can use import instead This file is being treated as an ES module because it has a ‘.js’ file extension and ‘package.json’ contains “type”: “module”. To treat it as a CommonJS script, rename it to use the ‘.cjs’ file extension.
What’s the benefit of doing this? This is confusing because you’re mixing ESM and CommonJS. The JS ecosystem is adopting ESM, and it makes sense to encourage the use of ESM imports where possible.
So at the moment it seems very difficult / impossible to do anything fancy with tailwind and Bud when you’re not proficient in ES modules. I cannot figure out how to access tailwind defaultTheme variables with Bud.
I also have lots of custom tailwind plugins that work for old versions of sage and all versions of Laravel, yet they don’t work for bud. I can’t figure out how to convert them.