rails_vite 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91b0886dc15d735ad8fa231e9f5acca53a5bd868022edb35c3d973e7246215d7
4
- data.tar.gz: f8c760fc635818a7c3c82e9c88728235098df743c4ae125cf9e6bc52bbab5999
3
+ metadata.gz: e0866cfdef70a06feb58cd405f2cdd7c7f9ddcb097871ac6fb272041b00083e9
4
+ data.tar.gz: b9ddef44f6b0e08d780f034a6927cb778f4ffd2a9435ccbdac1aa24e1e989251
5
5
  SHA512:
6
- metadata.gz: 61497d27c8e96429068b4417eb5252f89c8410026dc2ff60d14d427a777c808481359b168c7df1c6a3988cde93b8de77b3ec25c9270da2769da648095c372e17
7
- data.tar.gz: 8dd1e105346412b8a8008fbfb1383fb5fd4b7bacdaab66f6c6af10238987560aa21f09ae09e6ebdfc70bcbfab5f50da2e4063e9f300a9557f9c44521c1434930
6
+ metadata.gz: bea54a2fe1632fb4f4abe14e5bb0d5f8acd4fae71c24107b667dce65eeb144744e62fada3fff4c5eceaccbd5f70ab749dbd555fcdf0f109b39789abc29aa13f4
7
+ data.tar.gz: 01bd405f1b316d45814e8df8fbf18d8ab6f00169620262784a4bc41ca4964b6bf0ea6a8a1dc18b697cb72f6154563cd16060a1f3546cdb90df68e038c20702bd
data/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ 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
+ ## [0.2.1] - 2026-03-17
9
+
10
+ ### Added
11
+
12
+ - Vite 8 (Rolldown) compatibility — support `rolldownOptions` alongside `rollupOptions` ([@skryukov])
13
+ - Test mode isolation — build to `public/vite-test/` in test mode so test builds don't clobber dev/prod assets ([@skryukov])
14
+ - Define `assets:precompile` and `assets:clobber` rake tasks when no asset pipeline is present ([@skryukov])
15
+
16
+ ### Fixed
17
+
18
+ - Fix `?url` imports and asset references pointing to Rails server instead of Vite dev server ([@skryukov])
19
+ - Fix embedded Vite instances (Storybook) overwriting dev stubs in jsbundling mode ([@skryukov])
20
+
8
21
  ## [0.2.0] - 2026-03-11
9
22
 
10
23
  ### Added
@@ -43,7 +56,8 @@ and this project adheres to [Semantic Versioning].
43
56
 
44
57
  [@skryukov]: https://github.com/skryukov
45
58
 
46
- [Unreleased]: https://github.com/skryukov/rails_vite/compare/v0.2.0...HEAD
59
+ [Unreleased]: https://github.com/skryukov/rails_vite/compare/v0.2.1...HEAD
60
+ [0.2.1]: https://github.com/skryukov/rails_vite/compare/v0.2.0...v0.2.1
47
61
  [0.2.0]: https://github.com/skryukov/rails_vite/compare/v0.1.2...v0.2.0
48
62
  [0.1.2]: https://github.com/skryukov/rails_vite/compare/v0.1.1...v0.1.2
49
63
  [0.1.1]: https://github.com/skryukov/rails_vite/compare/v0.1.0...v0.1.1
data/README.md CHANGED
@@ -142,7 +142,7 @@ Use `import.meta.glob` in your entry point to include assets in the Vite manifes
142
142
 
143
143
  ```js
144
144
  // app/javascript/application.js
145
- import.meta.glob(['../assets/images/**']);
145
+ import.meta.glob(['../assets/images/**'], { eager: true });
146
146
  ```
147
147
 
148
148
  Then reference them in views:
@@ -173,10 +173,10 @@ export default defineConfig({
173
173
  | `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` |
174
174
  | `sourceDir` | `'app/javascript'` | Source directory. Short names are prefixed with this. Also sets the `@` import alias |
175
175
  | `ssr` | — | SSR entry point |
176
- | `ssrOutputDirectory` | `'ssr'` | SSR output directory |
176
+ | `ssrOutDir` | `'ssr'` | SSR output directory |
177
177
  | `devMetaFile` | `'tmp/rails-vite.json'` | Dev metadata file path |
178
- | `buildDirectory` | `'vite'` | Build output subdirectory inside `public/` |
179
- | `publicDirectory` | `'public'` | Public directory |
178
+ | `buildDir` | `'vite'` | Build output subdirectory inside `public/` |
179
+ | `publicDir` | `'public'` | Public directory |
180
180
  | `refresh` | `true` | Paths to watch for full-page reload. `true` watches `app/views/**` and `app/helpers/**` |
181
181
 
182
182
  ### Multiple Entry Points
@@ -252,7 +252,7 @@ export default defineConfig({
252
252
 
253
253
  ## SSR
254
254
 
255
- Set `ssr` to the entry point used for server-side rendering. When you run `npx vite build --ssr`, the plugin uses this as the input and outputs to the `ssrOutputDirectory` (default: `ssr/`).
255
+ Set `ssr` to the entry point used for server-side rendering. When you run `npx vite build --ssr`, the plugin uses this as the input and outputs to the `ssrOutDir` (default: `ssr/`).
256
256
 
257
257
  ```typescript
258
258
  rails({
@@ -405,7 +405,7 @@ In development, jsbundling mode writes `tmp/rails-vite.json` — the same file t
405
405
  ```json
406
406
  // package.json — replace vite-plugin-ruby with rails-vite-plugin
407
407
  - "vite-plugin-ruby": "^5.1.1"
408
- + "rails-vite-plugin": "^0.1.0"
408
+ + "rails-vite-plugin": "^0.2.0"
409
409
  ```
410
410
 
411
411
  ### 2. Replace `vite.config.ts`
@@ -2,18 +2,22 @@ module RailsVite
2
2
  class Config
3
3
  META_FILENAME = "rails-vite.json"
4
4
 
5
- attr_writer :dev_meta_path, :manifest_path, :asset_prefix, :auto_build
5
+ attr_writer :dev_meta_path, :manifest_path, :asset_prefix, :auto_build, :build_dir
6
6
 
7
7
  def dev_meta_path
8
8
  @dev_meta_path || Rails.root.join("tmp", META_FILENAME)
9
9
  end
10
10
 
11
+ def build_dir
12
+ @build_dir || (Rails.env.test? ? "vite-test" : "vite")
13
+ end
14
+
11
15
  def manifest_path
12
- @manifest_path || Rails.root.join("public/vite/manifest.json")
16
+ @manifest_path || Rails.root.join("public", build_dir, "manifest.json")
13
17
  end
14
18
 
15
19
  def asset_prefix
16
- @asset_prefix || "/vite"
20
+ @asset_prefix || "/#{build_dir}"
17
21
  end
18
22
 
19
23
  def source_dir
@@ -30,6 +34,7 @@ module RailsVite
30
34
  end
31
35
 
32
36
  def dev_server_running?
37
+ return false if Rails.env.test?
33
38
  !!dev_server_url
34
39
  end
35
40
 
@@ -31,7 +31,9 @@ module RailsVite
31
31
  end
32
32
 
33
33
  def build_command
34
- command_for(:build)
34
+ cmd = command_for(:build)
35
+ cmd += " --mode test" if Rails.env.test?
36
+ cmd
35
37
  end
36
38
 
37
39
  def tool
@@ -1,3 +1,3 @@
1
1
  module RailsVite
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -20,10 +20,24 @@ namespace :vite do
20
20
  end
21
21
 
22
22
  unless ENV["SKIP_VITE_BUILD"]
23
- %w[assets:precompile test:prepare spec:prepare db:test:prepare].each do |t|
24
- Rake::Task[t].enhance(["vite:build"]) if Rake::Task.task_defined?(t)
25
- break if %w[test:prepare spec:prepare].include?(t) && Rake::Task.task_defined?(t)
23
+ if Rake::Task.task_defined?("assets:precompile")
24
+ Rake::Task["assets:precompile"].enhance(["vite:build"])
25
+ else
26
+ desc "Compile assets"
27
+ Rake::Task.define_task("assets:precompile" => "vite:build")
26
28
  end
27
29
 
28
- Rake::Task["assets:clobber"].enhance(["vite:clobber"]) if Rake::Task.task_defined?("assets:clobber")
30
+ if Rake::Task.task_defined?("assets:clobber")
31
+ Rake::Task["assets:clobber"].enhance(["vite:clobber"])
32
+ else
33
+ desc "Remove compiled assets"
34
+ Rake::Task.define_task("assets:clobber" => "vite:clobber")
35
+ end
36
+
37
+ %w[test:prepare spec:prepare db:test:prepare].each do |t|
38
+ if Rake::Task.task_defined?(t)
39
+ Rake::Task[t].enhance(["vite:build"])
40
+ break
41
+ end
42
+ end
29
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_vite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov