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

After upgrading to Vite 4.2.0, running build multiple times resulted in 2 different hashes, for the same files #362

Open
dmix opened this issue May 2, 2023 · 1 comment

Comments

@dmix
Copy link

dmix commented May 2, 2023

Description 📖

I originally posted an issue on the vite repo (vitejs/vite#13071) but upon further investigation I think it might be more relevant here.

We recently tried deploying our Rails7 + Vue 3 + Vite 4.2.0 (from Vite 2.9) update and since we have multiple app servers we noticed that when Capistrano ran precompile it generated two different hashes on different servers (and only two).

I reproduced this locally so it's not just an issue with our servers.

The difference between the files:

    ../../public/vite/assets/application-8f133cfb.js 

    nne = function (e) {
        return "/vite/" + e;
    },
    ../../public/vite/assets/application-06ecfed2.js

    nne = function (e) {
        return "https://xyz.cloudfront.net/vite/" + e;
    },

It seems the first one 8f133cfb happened after the first build but re-running bundle exec vite build --force multiple times continually produced 06ecfed2 (with the proper CDN path).

Any ideas on why it might not be inserting the CDN the first time around?

We're attempting to try Vite 4.3.4 at the moment to see if it helps...


System info

package.json:

"@vitejs/plugin-vue": "4.1.0",
"@vitejs/plugin-vue-jsx": "3.0.0",
"vite": "2.9.13",
"vite-plugin-ruby": "3.0.12",
"vue": "3.2.47",

Gemfile.lock

    vite_rails (3.0.14)
      railties (>= 5.1, < 8)
      vite_ruby (~> 3.0, >= 3.2.2)
    vite_ruby (3.3.0)
      dry-cli (>= 0.7, < 2)
      rack-proxy (~> 0.6, >= 0.6.1)
      zeitwerk (~> 2.2)
@dmix dmix added the bug: pending triage Something doesn't seem to be working, but hasn't been verified label May 2, 2023
@ElMassimo ElMassimo added bug: needs reproduction and removed bug: pending triage Something doesn't seem to be working, but hasn't been verified labels May 3, 2023
@ElMassimo
Copy link
Owner

ElMassimo commented May 3, 2023

Hi Daniel!

Based on the example you provided, and assuming you are configuring asset_host in Rails, you might want to check the build output to verify that it's not printing this error the first time.

To discard whether this is the problem, I'd suggest explicitly configuring VITE_RUBY_ASSET_HOST, and see whether that prevents the problem.


Vite Rails will attempt to load the Rails app before building, in order to access the action_controller.asset_host as configured in the current environment (RAILS_ENV).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants