vite_rails 1.0.6 โ 1.0.7
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 +4 -0
- data/README.md +20 -64
- data/lib/vite_rails/helper.rb +7 -2
- data/lib/vite_rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f4c178774d28f47732953d6d672db2b2551030534b7a607f157e4692e992160
|
4
|
+
data.tar.gz: 9cb4eeab752ca23b2857487b1217d7e3f5b73afa72663ea8e01372328129368f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ce8a2425f5eeaac8715f6204ec19b80d7b215dfe427cd765f25023c0fb82e72b086cf883e0e36931b4ae8f70457910fd57d21a59258befe139456e89bb130e
|
7
|
+
data.tar.gz: e693145af6596c602eac3136ada51393bf2dd9e06d5d8372739dbef84d811cc8bc3e689411ba308f8535bbeafa0356e8f26452342d2bba9a05132fd839588623
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,26 +19,30 @@
|
|
19
19
|
</p>
|
20
20
|
</h1>
|
21
21
|
|
22
|
+
[website]: https://vite-rails.netlify.app/
|
23
|
+
[features]: https://vite-rails.netlify.app/guide/introduction.html
|
24
|
+
[guides]: https://vite-rails.netlify.app/guide/
|
25
|
+
[config]: https://vite-rails.netlify.app/config/
|
22
26
|
[vite_rails]: https://github.com/ElMassimo/vite_rails
|
23
27
|
[webpacker]: https://github.com/rails/webpacker
|
24
28
|
[vite]: http://vitejs.dev/
|
25
29
|
[config file]: https://github.com/ElMassimo/vite_rails/blob/main/package/default.vite.json
|
26
30
|
|
27
|
-
[__Vite Rails__][vite_rails] allows you to use [Vite] to power the frontend.
|
31
|
+
[__Vite Rails__][vite_rails] allows you to use [Vite] to power the frontend of your Rails app.
|
28
32
|
|
29
33
|
[Vite] is to frontend tooling as Ruby to programming, pure joy! ๐
|
30
34
|
|
31
35
|
## Features โก๏ธ
|
32
36
|
|
33
|
-
- ๐ค Automatic
|
34
|
-
- โก๏ธ
|
35
|
-
-
|
36
|
-
- ๐ค Integrated with <kbd>assets:precompile</kbd>
|
37
|
-
- And more!
|
37
|
+
- ๐ค Automatic entrypoint detection
|
38
|
+
- โก๏ธ Blazing fast hot reload
|
39
|
+
- ๐ Zero-config deployments
|
40
|
+
- ๐ค Integrated with <kbd>assets:precompile</kbd>
|
41
|
+
- [And more!][features]
|
38
42
|
|
39
43
|
## Documentation ๐
|
40
44
|
|
41
|
-
|
45
|
+
Visit the [documentation website][website] to check out the [guides] and searchable [configuration reference].
|
42
46
|
|
43
47
|
## Installation ๐ฟ
|
44
48
|
|
@@ -57,70 +61,22 @@ bin/rake vite:install
|
|
57
61
|
|
58
62
|
This will generate configuration files and a sample setup.
|
59
63
|
|
60
|
-
|
64
|
+
Additional installation instructions are available in the [documentation website][website].
|
61
65
|
|
62
|
-
|
63
|
-
will be considered entries to your application (SPAs or pages).
|
66
|
+
## Getting Started ๐ป
|
64
67
|
|
65
|
-
|
66
|
-
for you.
|
68
|
+
Restart your Rails server, and then run `bin/vite` to start the Vite development server.
|
67
69
|
|
68
|
-
|
70
|
+
Add the following your `views/layouts/application.html.erb`:
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
```js
|
74
|
-
import { createApp } from 'vue'
|
75
|
-
import App from '~/App.vue'
|
76
|
-
import '~/channels'
|
77
|
-
|
78
|
-
createApp(App).mount('#app')
|
72
|
+
```erb
|
73
|
+
<%= vite_client_tag %>
|
74
|
+
<%= vite_javascript_tag 'application' %>
|
79
75
|
```
|
80
76
|
|
81
|
-
|
82
|
-
|
83
|
-
`vite_typescript_tag`, `vite_javascript_tag`, and `vite_stylesheet_tag` can be
|
84
|
-
used to output `<script>` and `<link>` tags in your Rails layouts or templates.
|
85
|
-
|
86
|
-
```html
|
87
|
-
<head>
|
88
|
-
<title>Joie</title>
|
89
|
-
<%= csrf_meta_tags %>
|
90
|
-
<%= csp_meta_tag %>
|
91
|
-
|
92
|
-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
93
|
-
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
|
94
|
-
|
95
|
-
<%= vite_stylesheet_tag 'strange' %>
|
96
|
-
<%= vite_typescript_tag 'application' %>
|
97
|
-
</head>
|
98
|
-
```
|
99
|
-
|
100
|
-
For other types of assets, you can use `vite_asset_path` and pass that to the appropriate tag helper.
|
101
|
-
|
102
|
-
## Configuration โ๏ธ
|
103
|
-
|
104
|
-
This is what your `config/vite.json` might look like:
|
105
|
-
|
106
|
-
```json
|
107
|
-
{
|
108
|
-
"all": {
|
109
|
-
"watchAdditionalPaths": []
|
110
|
-
},
|
111
|
-
"development": {
|
112
|
-
"autoBuild": true,
|
113
|
-
"publicOutputDir": "vite-dev",
|
114
|
-
"port": 3036
|
115
|
-
},
|
116
|
-
"test": {
|
117
|
-
"autoBuild": true,
|
118
|
-
"publicOutputDir": "vite-test"
|
119
|
-
}
|
120
|
-
}
|
121
|
-
```
|
77
|
+
Visit any page and you should see a printed console output: `Vite โก๏ธ Rails`.
|
122
78
|
|
123
|
-
|
79
|
+
For more [guides] and a full [configuration reference], check the [documentation website][website].
|
124
80
|
|
125
81
|
## Inspiration ๐ก
|
126
82
|
|
data/lib/vite_rails/helper.rb
CHANGED
@@ -9,6 +9,11 @@ module ViteRails::Helper
|
|
9
9
|
ViteRails.instance
|
10
10
|
end
|
11
11
|
|
12
|
+
# Public: Renders a script tag for vite/client to enable HMR in development.
|
13
|
+
def vite_client_tag
|
14
|
+
content_tag('script', '', src: '/@vite/client', type: 'module') if ViteRails.dev_server_running?
|
15
|
+
end
|
16
|
+
|
12
17
|
# Public: Computes the relative path for the specified given Vite asset.
|
13
18
|
#
|
14
19
|
# Example:
|
@@ -28,12 +33,12 @@ module ViteRails::Helper
|
|
28
33
|
js_entries = names.map { |name| current_vite_instance.manifest.lookup!(name, type: asset_type) }
|
29
34
|
js_tags = javascript_include_tag(*js_entries.map { |entry| entry['file'] }, type: type, crossorigin: crossorigin, **options)
|
30
35
|
|
31
|
-
unless skip_preload_tags || ViteRails.
|
36
|
+
unless skip_preload_tags || ViteRails.dev_server_running?
|
32
37
|
preload_paths = js_entries.flat_map { |entry| entry['imports'] }.compact.uniq
|
33
38
|
preload_tags = preload_paths.map { |path| preload_link_tag(path, crossorigin: crossorigin) }
|
34
39
|
end
|
35
40
|
|
36
|
-
unless skip_style_tags || ViteRails.
|
41
|
+
unless skip_style_tags || ViteRails.dev_server_running?
|
37
42
|
style_paths = names.map { |name| current_vite_instance.manifest.lookup(name, type: :stylesheet)&.fetch('file') }.compact
|
38
43
|
style_tags = stylesheet_link_tag(*style_paths)
|
39
44
|
end
|
data/lib/vite_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vite_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mรกximo Mussini
|
@@ -186,8 +186,8 @@ homepage: https://github.com/ElMassimo/vite_rails
|
|
186
186
|
licenses:
|
187
187
|
- MIT
|
188
188
|
metadata:
|
189
|
-
source_code_uri: https://github.com/ElMassimo/vite_rails/tree/v1.0.
|
190
|
-
changelog_uri: https://github.com/ElMassimo/vite_rails/blob/v1.0.
|
189
|
+
source_code_uri: https://github.com/ElMassimo/vite_rails/tree/v1.0.7
|
190
|
+
changelog_uri: https://github.com/ElMassimo/vite_rails/blob/v1.0.7/CHANGELOG.md
|
191
191
|
post_install_message:
|
192
192
|
rdoc_options: []
|
193
193
|
require_paths:
|