ReferenceError: require is not defined in ES module scope, you can use import instead
The output says to replace .js files with .cjs but that causes all kinds of headaches.
Converting all of my old plugins for imports is a massive pain too. The tailwind docs don’t seem to be compatible with the way sage / bud loads tailwind.config.js.
Is it possible to load Tailwind without ES modules?
ReferenceError: require is not defined in ES module scope, you can use import instead
Per the error, you can use import
Ignoring your customizations you’ve already made to the Tailwind config, this is what a default Sage 10 install’s Tailwind config would look like for handling the forms plugin:
import forms from '@tailwindcss/forms';
/** @type {import('tailwindcss').Config} config */
const config = {
content: ['./app/**/*.php', './resources/**/*.{php,vue,js}'],
theme: {
extend: {
colors: {}, // Extend Tailwind's default colors
},
},
plugins: [
forms, // Use the imported forms plugin here
],
};
export default config;
You should be able to follow the example above, and in the other topic you came from, to work with other plugins as well
It’s definitely a headache figuring this out for the first time when coming from CJS.
Hopefully it won’t be too much of a pain once you start getting the hang of it. GPT is also great at handling tasks like this.
It’s a bit surprising that Tailwind docs still haven’t accounted for folks using ESM, but I’d be willing to bet that will change in the upcoming v4 release.