Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File references lost in production #69

Closed
E2design opened this issue Oct 24, 2021 · 9 comments
Closed

File references lost in production #69

E2design opened this issue Oct 24, 2021 · 9 comments
Labels

Comments

@E2design
Copy link

Describe the bug

Since the latest releases of the Vite build & the Vite plugin the site in production mode seems to have lost connection to the build files. The files are build and correctly moved into the css/dist directory. But while opening the page in production (useDevServer' => false) there are no file references in the HEAD to these files.

I've installed a new version nystudio/craft vite set-up in a fresh new docker. And even with that setup the same issue occurs.

To reproduce

Steps to reproduce the behaviour:

  1. Change vite.php to production (useDevServer' => false)
  2. Make build
  3. Files are build see this screenshot
  4. Refresh web page

Screenshots

If applicable, add screenshots to help explain your problem.

Versions

  • Plugin version: Vite plugin 1.0.17
  • Craft version: 3.7.17.2
@E2design E2design added the bug label Oct 24, 2021
@khalwat
Copy link
Contributor

khalwat commented Oct 24, 2021

Have you looked at the generated manifest.json to see if all of the expected files are there?

@E2design
Copy link
Author

Yepp all files are there.

@khalwat
Copy link
Contributor

khalwat commented Oct 25, 2021

Okay, I know what this is...

The build setup that used to work in Vite pre 2.6, but now appears to be broken. In the Vite root dir, I have an alias src/ that aliases to a directory outside of the Vite root. This is done for organizational purposes, when I build with manifest: true to output a manifest.json, the keys in the manifest used to look like this:

  "src/js/app.ts": {

but now it resolves the alias as part of the path:

  "../src/web/assets/src/js/app.ts": {

...which is not the desired result. Changing resolve.preserveSymlinks doesn't seem to have any effect.

I'll be creating a minimum reproducible repository, and filing an issue on the Vite issues page shortly.

@khalwat
Copy link
Contributor

khalwat commented Oct 25, 2021

Filed an issue: vitejs/vite#5415

@E2design
Copy link
Author

Would there be any temporary work around? Facing a live production soon.

@khalwat
Copy link
Contributor

khalwat commented Oct 28, 2021

Yeah you can just move the src/ dir to where the alias is, and it should fix everything for now

I've considered adding a patch fix to the Vite plugin to work around the situation too, because I do want to keep the alias/file structure in place

@PjGeeroms
Copy link

PjGeeroms commented Dec 1, 2021

For me personally on build it did not generate the complete path, it instead generated a key like this
../src/js/app.js. Changing the path to the script accordingly fixed the issue for me. Maybe because I created the alias with ln -nfs that it is actually following the alias now that makes key different.

(Using Vite 2.6.14)

@khalwat
Copy link
Contributor

khalwat commented Dec 1, 2021

They've apparently addressed this in Vite 2.7.0-beta.4 -- I plan to have a look at it shortly.

@khalwat
Copy link
Contributor

khalwat commented Dec 6, 2021

Confirmed fixed in ^2.7.0-beta.10 -- vitejs/vite#5415 (comment)

@khalwat khalwat closed this as completed Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants