Skip to content

staticPlugin cannot embed static files to singlefile #1713

@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 v1.3.8

Are you using dynamic mode?

false

What steps can reproduce the bug?

My project file tree

- dist-frontend
  - assets
    - index.css
    - index.js
  - index.html
- src
  - index.ts
- build.ts
- package.json

index.ts

import Elysia from 'elysia'
import { staticPlugin } from '@elysiajs/static'

for (const blob of Bun.embeddedFiles) {
  console.log(blob)
}
export const app = new Elysia().use(
  await staticPlugin({
    prefix: '/',
    assets: 'dist-frontend',
    indexHTML: true,
  }),
).listen(3000)

build.ts

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

What is the expected behavior?

copy singlefile to other computer can work.

What do you see instead?

move dist/app to other path or other computer, it cannot work, got error, and the Bun.embeddedFiles is empty

ENOENT: no such file or directory, open '/Users/seepine/workspace/elysia/elysia-app/dist-frontend/dist-frontend'
    path: "/Users/seepine/workspace/elysia/elysia-app/dist-frontend\u0000",
 syscall: "open",
   errno: -2,
    code: "ENOENT"

Additional information

No response

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

No response

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