Replies: 1 comment
-
I was able to get vite dev server to run by putting these two lines at the top of my tailwind.config.js file: import { createRequire } from 'module'; I could have gone back and required the tailwind plugins as in the tw docs, but they work as ES modules already, so I left it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried to make a bug report in issues but I don't know how to set up a reproduction so could not do that. But "require" is not supported with the latest laravel/vite/node. I had the same issue with setting up the tailwind plugins and had to use the import syntax to load those. When I use "require" in the plugins section of tailwind.config.js, I get the following error:
`ReferenceError: require is not defined
at file:///app/tailwind.config.js:22:5
at ModuleJobSync.runSync (node:internal/modules/esm/module_job:367:35)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:325:47)
at loadESMFromCJS (node:internal/modules/cjs/loader:1392:24)
at Module._compile (node:internal/modules/cjs/loader:1525:5)
at Object..js (node:internal/modules/cjs/loader:1680:16)
at Module.load (node:internal/modules/cjs/loader:1328:32)
at Function._load (node:internal/modules/cjs/loader:1138:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
Node.js v23.0.0`
Research led to the conclusion that require is for CommonJS modules and Vite uses ES modules. In order to install the tailwind plugins I had to do this:
`import forms from '@tailwindcss/forms'
import typography from '@tailwindcss/typography'
import aspectRatio from '@tailwindcss/aspect-ratio'
/** @type {import('tailwindcss').Config} */
export default {
content: [...],
theme: {...},
plugins: [
forms,
typography,
aspectRatio
],
}`
Adding
, require('flyonui'), require('flyonui/plugin')
to the tailwind.config.js file produced the same reference error. I don't know how to import flyonui.
Beta Was this translation helpful? Give feedback.
All reactions