Using an ES module in TailwindCSS config (Using React and Craco)

Viewed 1018

I've been trying for hours to import the package d3-colors into my tailwind.config.js. No solutions I have found on the internet have worked so far.

I have tried:

  • Converting it to tailwind.config.mjs, but then it doesn't get loaded. The configuration does not work.

  • Using the await import('colors-d3') but that doesn't work either because then I have to await the function that gets it, and that's not allowed either:

module.exports = await config();
SyntaxError: await is only valid in async functions and the top level bodies of modules
  • I've tried changing the package to type='module', but then I have all sorts of issues with Craco not being able to load it's config once I convert it to an ESM module because craco itself is commonjs.

  • I have tried modifying Craco's config...

  • I've tried using a postcss config file to pass the tailwind.config.mjs as the config file parameter, doesn't work either.

etc etc

I can't get it to work. How can I just import this module into my tailwind config?

1 Answers
Related