Code Monkey home page Code Monkey logo

Comments (10)

ElMassimo avatar ElMassimo commented on May 18, 2024 1

Please share the structure of your sourceCodeDir, and the contents of config/vite.json and vite.config.js, and the version of vite.

Try starting the dev server by running bin/vite dev or npx vite, which should output more detailed problems.

If that does not work, try deleting built assets and compile manually: bin/rake vite:clobber and bin/vite build, and make sure it compiles successfully.

There's an example Rails app on this repo that you can check to verify your setup (entrypoints, source code location, etc).

from vite_ruby.

cj avatar cj commented on May 18, 2024

I have also seen this error:

The server is configured with a public base URL of /vite-dev/ - did you mean to visit /vite-dev/application.js instead?

When visiting the URL from:

The resource at “http://localhost:3000/vite-dev/application.js” preloaded with link preload was not used within a few seconds. Make sure all attributes of the preload tag are set correctly.

from vite_ruby.

cj avatar cj commented on May 18, 2024

I am also randomly seeing this in the rails logs:

ActionController::RoutingError (No route matches [GET] "/vite-dev/@fs/Users/cj/Documents/apps/SnapNHD/snap/node_modules/.vite/debounced.js"):


ActionController::RoutingError (No route matches [GET] "/vite-dev/@fs/Users/cj/Documents/apps/SnapNHD/snap/app/assets/channels/index.js"):

from vite_ruby.

cj avatar cj commented on May 18, 2024

@ElMassimo here are the contents of those files https://gist.github.com/cj/e9f978c5d1c59ba0757b1ba0a5483f0d (I have also tried removing the babel plugin).

CleanShot 2021-03-01 at 09 10 13

bin/vite dev is what I use to run the server when developing.

This is what I used as an example to make sure mine was setup correctly https://github.com/ElMassimo/vite_ruby/tree/main/examples/rails

I will try and get you a standalone repo today/tomorrow, thank you again for taking a look!

from vite_ruby.

cj avatar cj commented on May 18, 2024

@ElMassimo here is also a full output of the rails console logs when starting up https://gist.github.com/cj/506fe28316a4216767fd56f1537de18f

from vite_ruby.

ElMassimo avatar ElMassimo commented on May 18, 2024

A standalone repo would be great, thanks.

I won't have computer access until Wednesday, I'll take a look then.

Looking at the traces you added, something that seems odd is that these requests are not being forwarded to Vite by the dev server proxy, can you check that it's being included in the Rack middleware? Also, which Vite version are you using?

Sidenote: The components folder should live inside your source code dir (app/assets), or make sure to add it to watchAdditionalPaths so that changes are detected by Vite Ruby for recompilation when the dev server has not started.

from vite_ruby.

cj avatar cj commented on May 18, 2024

@ElMassimo so looks like I figured out a temporary fix by increasing "devServerConnectTimeout": 30 from the default 0.1. It seems to randomly take 15+ seconds to compile sometimes, especially when loading async javascript imports. I am going to have to do some more digging to figure out why.

from vite_ruby.

ElMassimo avatar ElMassimo commented on May 18, 2024

The timeout should not be related with the compilation time, it's the timeout to check whether the dev server is running.

What hardware are you using, are you running in a VM or other resource-constrained environment?

@cj Make sure to add the components folder to your config/vite.json, otherwise changes to the components won't trigger a recompilation because they are outside your sourceCodeDir:

{
  "all": {
    "watchAdditionalPaths": ["app/components/**/*"]
  },

from vite_ruby.

ElMassimo avatar ElMassimo commented on May 18, 2024

Added a troubleshooting section describing possible causes.

Closing this for now, we can reopen it if none of the steps help, and you provide a reproduction 😃

from vite_ruby.

boriscy avatar boriscy commented on May 18, 2024

bin/rake vite:clobber and bin/vite build

Running these fixed my problems

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.