rails_vite 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -2
- data/README.md +75 -0
- data/lib/rails_vite/tag_helper.rb +8 -1
- data/lib/rails_vite/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91b0886dc15d735ad8fa231e9f5acca53a5bd868022edb35c3d973e7246215d7
|
|
4
|
+
data.tar.gz: f8c760fc635818a7c3c82e9c88728235098df743c4ae125cf9e6bc52bbab5999
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61497d27c8e96429068b4417eb5252f89c8410026dc2ff60d14d427a777c808481359b168c7df1c6a3988cde93b8de77b3ec25c9270da2769da648095c372e17
|
|
7
|
+
data.tar.gz: 8dd1e105346412b8a8008fbfb1383fb5fd4b7bacdaab66f6c6af10238987560aa21f09ae09e6ebdfc70bcbfab5f50da2e4063e9f300a9557f9c44521c1434930
|
data/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog],
|
|
6
6
|
and this project adheres to [Semantic Versioning].
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [0.2.0] - 2026-03-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- jsbundling mode — use Vite as a bundler with `jsbundling-rails` and Propshaft, no gem required ([@skryukov])
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- `vite_asset_path` now works in development ([@skryukov])
|
|
9
17
|
|
|
10
18
|
## [0.1.2] - 2026-03-08
|
|
11
19
|
|
|
@@ -35,7 +43,8 @@ and this project adheres to [Semantic Versioning].
|
|
|
35
43
|
|
|
36
44
|
[@skryukov]: https://github.com/skryukov
|
|
37
45
|
|
|
38
|
-
[Unreleased]: https://github.com/skryukov/rails_vite/compare/v0.
|
|
46
|
+
[Unreleased]: https://github.com/skryukov/rails_vite/compare/v0.2.0...HEAD
|
|
47
|
+
[0.2.0]: https://github.com/skryukov/rails_vite/compare/v0.1.2...v0.2.0
|
|
39
48
|
[0.1.2]: https://github.com/skryukov/rails_vite/compare/v0.1.1...v0.1.2
|
|
40
49
|
[0.1.1]: https://github.com/skryukov/rails_vite/compare/v0.1.0...v0.1.1
|
|
41
50
|
[0.1.0]: https://github.com/skryukov/rails_vite/commits/v0.1.0
|
data/README.md
CHANGED
|
@@ -16,6 +16,7 @@ Vite integration for Rails, inspired by [Laravel's Vite plugin](https://laravel.
|
|
|
16
16
|
- [Testing the Build](#testing-the-build)
|
|
17
17
|
- [Custom Paths](#custom-paths)
|
|
18
18
|
- [Rake Tasks](#rake-tasks)
|
|
19
|
+
- [jsbundling Mode](#jsbundling-mode)
|
|
19
20
|
- [Migrating from vite_rails](#migrating-from-vite_rails)
|
|
20
21
|
- [Contributing](#contributing)
|
|
21
22
|
- [License](#license)
|
|
@@ -317,6 +318,80 @@ Defaults match the plugin defaults — no config needed if you follow convention
|
|
|
317
318
|
`vite:build` hooks into `assets:precompile` and `test:prepare` automatically. Skip with `SKIP_VITE_BUILD=1`.
|
|
318
319
|
|
|
319
320
|
|
|
321
|
+
## jsbundling Mode
|
|
322
|
+
|
|
323
|
+
If you're using [`jsbundling-rails`](https://github.com/rails/jsbundling-rails) with Propshaft and want Vite as your bundler, you don't need the `rails_vite` gem — just the npm package:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
npm install -D rails-vite-plugin vite
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// vite.config.ts
|
|
331
|
+
import { defineConfig } from 'vite';
|
|
332
|
+
import jsbundling from 'rails-vite-plugin/jsbundling';
|
|
333
|
+
|
|
334
|
+
export default defineConfig({
|
|
335
|
+
plugins: [
|
|
336
|
+
jsbundling(),
|
|
337
|
+
],
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**How it works:** In production, Vite builds to `public/assets/` and copies entry files to `app/assets/builds/` so Propshaft can serve them via `javascript_include_tag` and `stylesheet_link_tag`. In development, the plugin writes stub files to `app/assets/builds/` that redirect the browser to Vite's dev server for HMR.
|
|
342
|
+
|
|
343
|
+
### jsbundling Options
|
|
344
|
+
|
|
345
|
+
| Option | Default | Description |
|
|
346
|
+
|--------|---------|-------------|
|
|
347
|
+
| `input` | auto-detected | Entry point(s). If `sourceDir/entrypoints/` exists, all files in it are used. Otherwise, detects `application.{js,ts,jsx,tsx}` in `sourceDir` |
|
|
348
|
+
| `sourceDir` | `'app/javascript'` | Source directory. Short names are prefixed with this. Also sets the `@` import alias |
|
|
349
|
+
| `assetPipelineDir` | `'app/assets/builds'` | Directory where Propshaft/Sprockets picks up entry files |
|
|
350
|
+
| `outputDir` | `'public/assets'` | Public directory for the full Vite build output |
|
|
351
|
+
| `ssr` | — | SSR entry point. String or `{ entry, outDir }` |
|
|
352
|
+
| `refresh` | — | Paths to watch for full-page reload. `true` watches `app/views/**` and `app/helpers/**` |
|
|
353
|
+
| `devMetaFile` | `'tmp/rails-vite.json'` | Dev metadata file path. Set to `false` to disable |
|
|
354
|
+
|
|
355
|
+
### Replacing esbuild
|
|
356
|
+
|
|
357
|
+
In your `Procfile.dev`, replace the esbuild command:
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
web: bin/rails server -p 3000
|
|
361
|
+
-js: yarn build --watch
|
|
362
|
+
+vite: npx vite
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
CSS and JS entries in `app/javascript/entrypoints/` are auto-discovered. Both `javascript_include_tag` and `stylesheet_link_tag` work unchanged — Propshaft resolves them from `app/assets/builds/` as before.
|
|
366
|
+
|
|
367
|
+
### Frameworks
|
|
368
|
+
|
|
369
|
+
React and Vue work the same as in the standard plugin — add the framework plugin before `jsbundling()`:
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { defineConfig } from 'vite';
|
|
373
|
+
import jsbundling from 'rails-vite-plugin/jsbundling';
|
|
374
|
+
import react from '@vitejs/plugin-react';
|
|
375
|
+
|
|
376
|
+
export default defineConfig({
|
|
377
|
+
plugins: [
|
|
378
|
+
react(),
|
|
379
|
+
jsbundling(),
|
|
380
|
+
],
|
|
381
|
+
});
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Upgrading to rails_vite
|
|
385
|
+
|
|
386
|
+
To switch from jsbundling mode to the full `rails_vite` gem:
|
|
387
|
+
|
|
388
|
+
1. Add `gem "rails_vite"` to your Gemfile and `bundle install`
|
|
389
|
+
2. Change the import in `vite.config.ts` from `rails-vite-plugin/jsbundling` to `rails-vite-plugin`
|
|
390
|
+
3. Replace `javascript_include_tag` / `stylesheet_link_tag` with `vite_tags` in your layouts
|
|
391
|
+
4. Remove `jsbundling-rails` from your Gemfile
|
|
392
|
+
|
|
393
|
+
In development, jsbundling mode writes `tmp/rails-vite.json` — the same file the `rails_vite` gem reads. You can add the gem and verify `vite_tags` works in dev before deploying.
|
|
394
|
+
|
|
320
395
|
## Migrating from vite_rails
|
|
321
396
|
|
|
322
397
|
### 1. Swap dependencies
|
|
@@ -27,7 +27,14 @@ module RailsVite
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def vite_asset_path(name)
|
|
30
|
-
|
|
30
|
+
config = RailsVite.config
|
|
31
|
+
resolved = resolve_vite_entry(name, config.source_dir, nil)
|
|
32
|
+
|
|
33
|
+
if config.dev_server_running?
|
|
34
|
+
"#{config.dev_server_url}/#{resolved}"
|
|
35
|
+
else
|
|
36
|
+
vite_asset_url(RailsVite.manifest.path_for(resolved))
|
|
37
|
+
end
|
|
31
38
|
end
|
|
32
39
|
|
|
33
40
|
def vite_image_tag(name, **options)
|
data/lib/rails_vite/version.rb
CHANGED