Giter Site home page Giter Site logo

Comments (9)

ElMassimo avatar ElMassimo commented on June 14, 2024 2

Good timing, I have something in the vite-5 branch, testing before releasing the gems.

from vite_ruby.

KieranP avatar KieranP commented on June 14, 2024 2

@ElMassimo You are right that the assets are preserved between deployments, a common practice with Capistrano in order to speed up deployment times. However, I feel that documentation may not be enough in this case. We didn't encounter any issues in development before we rolled out the change, so I imagine most people would not check Troubleshooting until it is already too late.

I think merging the old and the new should be considered incorrect behaviour. Perhaps a better approach may be to check the for presence of the manifests under .vite and use only those, otherwise fall back to the old manifests.

def known_manifest_paths
  manifest_files = [
    # NOTE: Generated by Vite when `manifest: true`, which vite-plugin-ruby enables.
    'manifest.json',
    # NOTE: Path where vite-plugin-ruby outputs the assets manifest file.
    'manifest-assets.json',
  ]

  vite5_manifest_paths = manifest_files.map { |path|
    build_output_dir.join(".vite/#{path}")
  }

  vite4_manifest_paths = manifest_files.map { |path|
    build_output_dir.join(path)
  }

  if vite5_manifest_paths.any? { |path| File.exists?(path) }
    vite5_manifest_paths
  else
    vite4_manifest_paths
  end
end

from vite_ruby.

KieranP avatar KieranP commented on June 14, 2024 2

@ElMassimo Here is a PR for the above suggested change. It seems to be working well on our deployments.

https://github.com/ElMassimo/vite_ruby/pull/432/files

from vite_ruby.

ElMassimo avatar ElMassimo commented on June 14, 2024 1

Closed in #421. Releasing a new version of vite_ruby soon.

from vite_ruby.

KieranP avatar KieranP commented on June 14, 2024 1

@ElMassimo We just run into an issue while upgrading from Vite 4 to Vite 5. After upgrade and deploy, we ended up with this file structure:

public/
  vite/
    manifest-assets.json
    manifest.json
    .vite/
      manifest-assets.json
      manifest.json

After the application rebooted, it was still loading the old JS assets from public/vite/manifest*. I had to SSH in, remove those old manifest files, restart the application server, then things came right. Is this expected? From what I can see of the commit, it should default to V5 manifest but doesn't appear to be working.

from vite_ruby.

majksner avatar majksner commented on June 14, 2024

After update to latest vite_rails manifest.json location has been changed and Rails fails to pickup new manifest. Is there is a workaround for this? I'm using Capistrano to deploy the app.

I have to do assets:clobber, assets:precompile and the restart server in order for Rails to pick up the latest build.

from vite_ruby.

ElMassimo avatar ElMassimo commented on June 14, 2024

You can configure assets_manifests to backup the new location, or configure Vite to output the manifest in the old location.

from vite_ruby.

majksner avatar majksner commented on June 14, 2024

Thanks! I was able to fix this issue by cleaning shared/public directory in Capistrano and adding public/vite to linked_dirs.

from vite_ruby.

ElMassimo avatar ElMassimo commented on June 14, 2024

Hi Kieran! In that case, it would load all four manifest files, unfortunately merging the old ones last since the new location is read first.

This problem would only happen when preserving assets from previous deployments (as opposed to when using containers).

Flipping the order would potentially avoid this problem during upgrades, but since it's a one-time thing I'm leaning towards documenting it in Troubleshooting instead.

from vite_ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.