Comments (4)
@Jonic If you are referring to Sidecar Assets, it should be possible to do something similar in Vite Ruby.
Instead of require.context
you would use a globEager
import.
Here's an example using globEager
to register all Stimulus controllers.
If you are referencing individual assets from Rails views or partials directly, then it's not going to be a drop-in replacement, but if you are combining the components in a single "pack" it should be easier.
would I be unable to reference the images with vite_asset_path since they're not in the entrypoints directory?
No. When using Vite.js you would ideally import
the images in the relevant component and use their source in the component itself.
from vite_ruby.
Hi Jonic!
The Troubleshooting guide is indeed misleading in this scenario, I will update it accordingly.
To answer your question, all tag helpers including vite_asset_path
can only reference files in the entrypoints
directory.
If you are only referencing images from any JS or CSS processed by Vite, you would be able to import them without placing them under entrypoints
.
from vite_ruby.
Updated the docs, removed the reference to an unrelated older issue in Vite, and clarified where the assets are located in the Rails vite_asset_path
example.
Thanks!
from vite_ruby.
@ElMassimo Thanks for the clarification - it's much clearer now! I was hoping to use Github's ViewComponent gem, keeping each component's assets with the Ruby class and erb
template, for example:
app/components/header_component
./header.rb
./header.erb
./header.scss
./header.js
./images/logo.svg
I understand that I'd have to import the Sass and JS from an entrypoint, and that these files can in turn load images, but would I be unable to reference the images with vite_asset_path
since they're not in the entrypoints
directory? I'm still trying to figure out if Vite Ruby could be an easy-ish drop-in replacement for our current setup, or if it would involve significant reshuffling and a massive PR to make it all happen. Apologies if I'm being dense!
from vite_ruby.
Related Issues (20)
- exit code is 0 on error HOT 1
- Flaky tests due occasional error from ViteRuby::Manifest#path_for HOT 6
- CONTRIBUTING guide: running `pnpm install` rewrites lock file HOT 1
- Tests randomly fail when running entire rspec test suite (and don't when run alone) HOT 8
- New Rails app with `--skip-javascript` doesn't get a bin/vite file when running `bundle exec vite install` HOT 1
- Getting `error Command "vite" not found.` on Github actions HOT 2
- Feature request: vite_picture_tag HOT 1
- vite builds twice and points to wrong one on heroku HOT 2
- Vite runs on development but fails on production
- Dry::CLI::Command `delegate` method raises error when used in rails project HOT 4
- [Docker] `ViteRuby#dev_server_running?` always return `false` when rails and vite run in different containers with `skipProxy: true` HOT 1
- modulepreload links not setting correct `base` option defined in `vite.config.ts` HOT 4
- Print stylesheets not working with dev server HOT 1
- Refused to connect to 'ws://localhost:3036/vite-dev/' because it violates the following Content Security Policy directive: "default-src 'self' https:". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback. HOT 1
- Automatic refresh for SSR server HOT 1
- Some assets are randomly missing after deployment with Capistrano HOT 1
- yarn 3 Missing Executable
- How do I turn off the Inter-roman and Inter-italic fonts?
- Configurable option for location of vite.config.ts HOT 2
- Update rack-proxy to at least 0.7.5 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite_ruby.