ladle icon indicating copy to clipboard operation
ladle copied to clipboard

Ladle seems to conflict with remix vite plugin

Open sigma-andex opened this issue 1 year ago • 2 comments

Describe the bug

Ladle fails to start with the following error message when remix is in the vite.config:

[ENOENT: no such file or directory, open '/home/projects/ladle-xmfkzx/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@ladle/react/typings-for-build/app/package.json'] {
  code: 'ENOENT',
  errno: -2,
  path: '/home/projects/ladle-xmfkzx/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@ladle/react/typings-for-build/app/package.json',
  syscall: 'open',
  message: "Could not read package.json: Error: ENOENT: no such file or directory, open '/home/projects/ladle-xmfkzx/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@ladle/react/typings-for-build/app/package.json'"
}

Reproduction

See https://stackblitz.com/edit/ladle-xmfkzx?file=vite.config.ts

Environment

  • Version 4.0.2

sigma-andex avatar Apr 22 '24 11:04 sigma-andex

Any insights what that plugin is doing internally?

tajo avatar May 02 '24 17:05 tajo

Can confirm, I solved it by adding a specific ladle vite config without the remix plugin.

In ~/.vite.config.ts we exported our plugin settings so that we could reuse it in ./.ladle/vite.config.ts.

Use it then with: "dev:ladle": "ladle dev --viteConfig ./.ladle/vite.config.ts"

Would love to solve the issue, this is more a work around.

justb3a avatar May 06 '24 07:05 justb3a

Seems like Remix are aware of the issue, see here.

For now I just follow the Storybook way by exclude the remix plugin if I'm running the ladle CLI

const isLadle = process.argv[1]?.includes("ladle");

export default defineConfig({
  server: {
    port: 8081
  },
  // https://remix.run/docs/en/main/future/vite#plugin-usage-with-other-vite-based-tools-eg-vitest-storybook
  // refer to the link above to understand why we use process.env.VITEST or isLadle
  plugins: [
     !isLadle && remix(remixConfig),
    ...

andychongyz avatar May 29 '24 07:05 andychongyz

I guess this is not something we can fix on our side. People should follow their advice of excluding it for now as @andychongyz suggests.

tajo avatar May 30 '24 02:05 tajo