Giter Site home page Giter Site logo

Comments (5)

mattlong avatar mattlong commented on May 21, 2024 1

Sure thing, thanks for working on this! I've gotten tired of all of webpack's complexity and am hoping this can be viable alternative to webpacker!

from vite_ruby.

ElMassimo avatar ElMassimo commented on May 21, 2024

Hi there! Thanks for providing the logs.

It's unlikely that npx vite returns the same error as the other commands, as it doesn't run any Ruby code, where the CLI is defined.

Looking at the output of the info command, it would seem that vite-plugin-ruby and vite were not installed, likely due to a bug in the logic in this library's installation command which I'm planning to investigate tomorrow.

I have documented this common problem, and I'm planning to add a verification check to prevent silent failures when these packages are missing.

Please add vite-plugin-ruby and vite as development dependencies, install them (yarn, npm, pnpm, whatever you are using), and try again.

About the last comment, using the bin/vite executable ensures any config overrides added in Ruby are passed to Vite, such as Rails environment, but in most setups running npx vite is the same so feel free to add a script in your package.json if you prefer that, it will still read the config/vite.json configuration.

from vite_ruby.

mattlong avatar mattlong commented on May 21, 2024

After a bit more looking at the source, it seems the root problem is that npx @antfu/ni -D #{ deps } command is not actually adding the two deps as is being expected; hence my comments above them not showing up in my package.json after vite install. I'm not familiar with antfu/ni and not really sure why the command wouldn't be working as expected and apparently failing silently.

Manually running yarn add -D vite@^2.0.3 vite-plugin-ruby@^1.0.13 clears up the issue and bin/vite dev no longer exits immediately 🎊

To your comment about verification, I believe running npx vite without vite being installed locally would still work, no? It seems like a safer verification might be just making sure vite is listed as a dev dependency in package.json.

from vite_ruby.

ElMassimo avatar ElMassimo commented on May 21, 2024

Agreed, for verification I'm thinking of checking both the plugin and vite are installed.

I'll leave this open as a reminder to fix the installation (it seems the command is succeeding so the yarn fallback is not used, but it's not actually installing the packages), and to add the verification before the dev and build commands.

Thanks for the report!

from vite_ruby.

ElMassimo avatar ElMassimo commented on May 21, 2024

It has been for me! Vite's defaults are great, and at the same time it's very easy to configure (TypeScript-enabled config file), and to extend with plugins.

Webpack is great too, but it requires a significant amount of configuration and specific knowledge about its internals.

Because of that, webpacker attempts to provide an "out of the box" experience, which then makes it really hard to eject from if you want to instead use something like vue-cli.

That's why this library is intentionally narrow in scope: simplify Vite.js integration with Ruby, and get out of the way.

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.