Skip to content

staticPlugin cannot work with tailwindcss #1714

@seepine

Description

@seepine

What version of Elysia is running?

1.4.22

What platform is your computer?

Darwin 24.3.0 arm64 arm

What environment are you using

bun 1.3.8

Are you using dynamic mode?

false

What steps can reproduce the bug?

try https://elysiajs.com/patterns/fullstack-dev-server.html

src/index.ts

const app = new Elysia()
  .use(await staticPlugin({ prefix: '/' }))
  .listen(3000)

public/index.html

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Elysia React App</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="tailwindcss" />
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="./index.tsx"></script>
  </body>
</html>

public/index.tsx

import { useState } from 'react'
import { createRoot } from 'react-dom/client'

import '@public/global.css'

function App() {
  const [count, setCount] = useState(0)
  const increase = () => {
    setCount((c) => c + 1)
  }

  return (
    <main className="flex flex-col gap-4 justify-center items-center h-full">
      <h2>{count}</h2>
      <button onClick={increase}>Increase</Button>
    </main>
  )
}

const root = createRoot(document.getElementById('root')!)
root.render(<App />)

build.ts

import bunPluginTailwind from 'bun-plugin-tailwind'

const res = await Bun.build({
  entrypoints: ['src/index.ts'],
  target: 'bun',
  minify: true,
  sourcemap: 'linked',
  outdir: 'dist',
  compile: { outfile: 'app' },
  define: {
    'process.env.NODE_ENV': JSON.stringify('production'),
  },
  plugins: [bunPluginTailwind],
})

What is the expected behavior?

can work.

What do you see instead?

in dev it can work, but after build, and run ./dist/app got error

Could not resolve: "tailwindcss". Maybe you need to "bun install"?
Image

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions