htmlstreamofficial / preline

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
https://preline.co
Other
4.9k stars 309 forks source link

React + Vite -> require is not defined #511

Open Sladerix opened 2 days ago

Sladerix commented 2 days ago

Summary

crash right after the page is loaded, require in plugins section seems to not working correctly

Steps to Reproduce

I run the project with npm run dev but at the moment I reload/load the page everything crashes.

My Tailwind Config:

/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
    './node_modules/preline/preline.js',
  ],
  theme: {
    extend: {},
  },
  plugins: [
    require('preline/plugin'),
  ],
}

The error:

  VITE v5.4.8  ready in 140 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
(node:15821) ExperimentalWarning: CommonJS module /Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/tailwindcss/lib/lib/load-config.js is loading ES Module /Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/tailwind.config.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
file:///Users/antonellobarbone/Documents/Assegno%20di%20Ricerca/React%20DT%20Web%20Dashboard/dt-dashboard/tailwind.config.js:11
  plugins: [
           ^

ReferenceError: require is not defined
    at file:///Users/antonellobarbone/Documents/Assegno%20di%20Ricerca/React%20DT%20Web%20Dashboard/dt-dashboard/tailwind.config.js:11:12
    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:395:35)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:329:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1380:24)
    at Module._compile (node:internal/modules/cjs/loader:1532:5)
    at Object..js (node:internal/modules/cjs/loader:1702:10)
    at Module.load (node:internal/modules/cjs/loader:1307:32)
    at Function._load (node:internal/modules/cjs/loader:1121:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
    at Module.require (node:internal/modules/cjs/loader:1329:12)
    at require (node:internal/modules/helpers:136:16)
    at /Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/tailwindcss/lib/lib/load-config.js:54:27
    at loadConfig (/Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/tailwindcss/lib/lib/load-config.js:58:6)
    at getTailwindConfig (/Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:71:116)
    at /Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:100:92
    at /Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/tailwindcss/lib/processTailwindFeatures.js:46:11
    at plugins (/Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/tailwindcss/lib/plugin.js:38:69)
    at LazyResult.runOnRoot (/Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/postcss/lib/lazy-result.js:329:16)
    at LazyResult.runAsync (/Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/postcss/lib/lazy-result.js:258:26)
    at LazyResult.async (/Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/postcss/lib/lazy-result.js:160:30)
    at LazyResult.then (/Users/antonellobarbone/Documents/Assegno di Ricerca/React DT Web Dashboard/dt-dashboard/node_modules/postcss/lib/lazy-result.js:404:17)

Node.js v23.2.0

npm version is 10.9.0

Demo Link

cannot install tailwind or preline on codesandbox

Expected Behavior

No response

Actual Behavior

No response

Screenshots

No response