adonisjs / inertia

Official Inertia.js adapter for AdonisJS
MIT License
94 stars 10 forks source link

[vite] Pre-transform error. Tries to find TSX files in production build, with wrong url #27

Closed AlexandreLemoine40 closed 5 months ago

AlexandreLemoine40 commented 5 months ago

Package version

@adonisjs/inertia@1.1.0

Describe the bug

Capture d’écran 2024-06-25 à 13 58 31

Just basically created an Inertia project working perfectly in Dev mode but the production build is wrong, as it tries to find /inertia/..... in the project but inertia folder is not in the production build.

I've also removed inertia folder from the exclude path in the tsconfig but didn't change the result

Reproduction repo

No response

RomainLanz commented 5 months ago

Hey @AlexandreLemoine40! 👋🏻

Have you correctly set your NODE_ENV variable to production?

AlexandreLemoine40 commented 5 months ago

Hey @RomainLanz, Yes, as stated in the docs https://docs.adonisjs.com/guides/views-and-templates/inertia#why-my-production-build-is-not-working-

I'd really like to make it work as I'm a big fan of Adonis framework.

And btw there are other production build incoherences I'll raise issues for, concerning Lucid/Luxon imports builds

RomainLanz commented 5 months ago

And btw there are other production build incoherences I'll raise issues for, concerning Lucid/Luxon imports builds

You probably updated your TypeScript version to the latest release, which break some stuff. Please revert back as stated in our Discord and Twitter account.

https://x.com/adonisframework/status/1805309070833844475

Concerning your first issue, I would need a repository with the minimum amount of code to reproduce your issue.

AlexandreLemoine40 commented 5 months ago

Ok I'll downgrade TS and test again.

For the initial problem I just created my project using npm init adonisjs@latest my-project, and chose Inertia, TS, React, and Session auth. Ran the migrations to my database, ran npm build, cd build, npm ci omit command, and npm start. That's all.

Julien-R44 commented 5 months ago

It's pretty sure that you don't have NODE_ENV to production. image

This message comes from the Vite dev server when it starts up. Which means you don't have NODE_ENV at production. Vite dev server shouldn't start in production.

AlexandreLemoine40 commented 5 months ago
Capture d’écran 2024-06-25 à 14 30 09

my .env is in the build directory.

and still has the same effect

Capture d’écran 2024-06-25 à 14 31 05

Edit

I've added the NODE_ENV before the node bin/server.js and it is working now. Thanks

AlexandreLemoine40 commented 5 months ago

Needed to pass NODE_ENV=production in the node bin/server.js command line as NODE_ENV=production node bin/server.js