vite_rails 2.0.0 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -1
- data/README.md +7 -3
- data/lib/vite_rails/installation.rb +24 -10
- data/lib/vite_rails/tag_helpers.rb +2 -2
- data/lib/vite_rails/version.rb +1 -1
- data/templates/entrypoints/application.js +8 -0
- metadata +19 -56
- data/CONTRIBUTING.md +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb3c710a8f422261f267b758138a55eb592b02f97cb7de4714fd35956a40d140
|
4
|
+
data.tar.gz: 4ed1b9749d4759d6b3132829a6b1ebb1bd2617b7d2988fc8e812745f4428dec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfc702ca803be23639a8a3d3d9a5968846bb07b6b659a4b1d388de5bb92d788c3c903cc7f7f680a6e5a6760418b3bb0484ecda14ebc36be664ba76b9279c3a58
|
7
|
+
data.tar.gz: b46ce36b00362b4c47f009f1cbda0c789e0b59db4c819d0b9f5d286549757e6a4f4fd3fc0165b316d72cd127070a376295e4c9312800333c119170890b0fc4a5
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,38 @@
|
|
1
|
-
##
|
1
|
+
## [2.0.6](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.5...vite_rails@2.0.6) (2021-03-18)
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
## [2.0.5](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.4...vite_rails@2.0.5) (2021-03-18)
|
6
|
+
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
* Using a .jsx extension in a tag helper in development ([a56491b](https://github.com/ElMassimo/vite_ruby/commit/a56491b96720ae537b6b6305aa7efa70cf19e4ee))
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [2.0.4](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.3...vite_rails@2.0.4) (2021-03-09)
|
15
|
+
|
16
|
+
|
17
|
+
### Features
|
18
|
+
|
19
|
+
* Detect installations of the latest version of Webpacker (app/packs) ([e9a3bc0](https://github.com/ElMassimo/vite_ruby/commit/e9a3bc02475dbadac77e58b3980a4af8df5aaa02))
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
## [2.0.3](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.2...vite_rails@2.0.3) (2021-03-07)
|
24
|
+
|
25
|
+
- Add a bounded requirement to `vite_ruby` dependency.
|
26
|
+
|
27
|
+
## Vite Rails 2.0.2 (2020-02-11)
|
28
|
+
|
29
|
+
- Automatically infer `app/javascript` as the `sourceCodeDir` if it exists.
|
30
|
+
|
31
|
+
## Vite Rails 2.0.1 (2020-02-11)
|
32
|
+
|
33
|
+
- Add the CSP rules commented out when installing, in case the user hasn't uncommented them yet.
|
34
|
+
|
35
|
+
## Vite Rails 2.0.0 (2020-02-10)
|
2
36
|
|
3
37
|
- Extracted core functionality to `vite_ruby`.
|
4
38
|
- User-facing API hasn't really changed, but internal classes have been renamed.
|
data/README.md
CHANGED
@@ -59,8 +59,11 @@ dev server is extremely __fast to start__, and your changes will be __updated in
|
|
59
59
|
In production, Vite [bundles your code][bundling]
|
60
60
|
with tree-shaking, lazy-loading, and common chunk splitting out of the box, to achieve optimal loading performance.
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
It also provides great defaults, and is easier to configure than similar tools like webpack.
|
63
|
+
|
64
|
+
Check [this video comparison with webpack](https://github.com/ElMassimo/jumpstart-vite)
|
65
|
+
which demonstrates the difference in boot time, or [this one](https://github.com/ElMassimo/pingcrm-vite/pull/1)
|
66
|
+
with the difference in speed during development.
|
64
67
|
|
65
68
|
## Features ⚡️
|
66
69
|
|
@@ -79,7 +82,7 @@ Visit the [documentation website][website] to check out the [guides] and searcha
|
|
79
82
|
Add this line to your application's Gemfile:
|
80
83
|
|
81
84
|
```ruby
|
82
|
-
gem 'vite_rails'
|
85
|
+
gem 'vite_rails' # vite_rails_legacy if using Rails 4
|
83
86
|
```
|
84
87
|
|
85
88
|
Then, run:
|
@@ -107,6 +110,7 @@ Please use [Issues] to report bugs you find, and [Discussions] to make feature r
|
|
107
110
|
|
108
111
|
Don't hesitate to _⭐️ star the project_ if you find it useful!
|
109
112
|
|
113
|
+
Using it in production? Always love to hear about it! 😃
|
110
114
|
|
111
115
|
## Special Thanks 🙏
|
112
116
|
|
@@ -10,6 +10,9 @@ module ViteRails::Installation
|
|
10
10
|
# Override: Setup a typical apps/web Hanami app to use Vite.
|
11
11
|
def setup_app_files
|
12
12
|
cp RAILS_TEMPLATES.join('config/rails-vite.json'), config.config_path
|
13
|
+
if dir = %w[app/javascript app/packs].find { |path| root.join(path).exist? }
|
14
|
+
Dry::CLI::Utils::Files.replace_first_line config.config_path, 'app/frontend', %( "sourceCodeDir": "#{ dir }",)
|
15
|
+
end
|
13
16
|
setup_content_security_policy root.join('config/initializers/content_security_policy.rb')
|
14
17
|
end
|
15
18
|
|
@@ -17,28 +20,39 @@ module ViteRails::Installation
|
|
17
20
|
def setup_content_security_policy(csp_file)
|
18
21
|
return unless csp_file.exist?
|
19
22
|
|
20
|
-
inject_line_after csp_file, 'policy.script_src',
|
21
|
-
|
22
|
-
policy.script_src *policy.script_src, :blob if Rails.env.test?
|
23
|
+
inject_line_after csp_file, 'policy.script_src', <<~CSP
|
24
|
+
# You may need to enable this in production as well depending on your setup.
|
25
|
+
# policy.script_src *policy.script_src, :blob if Rails.env.test?
|
23
26
|
CSP
|
24
|
-
inject_line_after csp_file, 'policy.connect_src',
|
25
|
-
|
26
|
-
policy.connect_src *policy.connect_src, "ws://\#{ ViteRuby.config.host_with_port }" if Rails.env.development?
|
27
|
+
inject_line_after csp_file, 'policy.connect_src', <<~CSP
|
28
|
+
# Allow @vite/client to hot reload changes in development
|
29
|
+
# policy.connect_src *policy.connect_src, "ws://\#{ ViteRuby.config.host_with_port }" if Rails.env.development?
|
27
30
|
CSP
|
28
|
-
inject_line_after csp_file, 'policy.script_src',
|
29
|
-
|
30
|
-
policy.script_src *policy.script_src, :unsafe_eval, "http://#{ ViteRuby.config.host_with_port }" if Rails.env.development?
|
31
|
+
inject_line_after csp_file, 'policy.script_src', <<~CSP
|
32
|
+
# Allow @vite/client to hot reload changes in development
|
33
|
+
# policy.script_src *policy.script_src, :unsafe_eval, "http://#{ ViteRuby.config.host_with_port }" if Rails.env.development?
|
31
34
|
CSP
|
32
35
|
end
|
33
36
|
|
34
37
|
# Override: Create a sample JS file and attempt to inject it in an HTML template.
|
35
38
|
def install_sample_files
|
36
|
-
|
39
|
+
unless config.resolved_entrypoints_dir.join('application.js').exist?
|
40
|
+
cp RAILS_TEMPLATES.join('entrypoints/application.js'), config.resolved_entrypoints_dir.join('application.js')
|
41
|
+
end
|
37
42
|
|
38
43
|
if (layout_file = root.join('app/views/layouts/application.html.erb')).exist?
|
39
44
|
inject_line_before layout_file, '</head>', <<-HTML
|
40
45
|
<%= vite_client_tag %>
|
41
46
|
<%= vite_javascript_tag 'application' %>
|
47
|
+
<!--
|
48
|
+
If using a TypeScript entrypoint file:
|
49
|
+
vite_typescript_tag 'application'
|
50
|
+
|
51
|
+
If using a .jsx or .tsx entrypoint, add the extension:
|
52
|
+
vite_javascript_tag 'application.jsx'
|
53
|
+
|
54
|
+
Visit the guide for more information: https://vite-ruby.netlify.app/guide/rails
|
55
|
+
-->
|
42
56
|
HTML
|
43
57
|
end
|
44
58
|
end
|
@@ -26,7 +26,7 @@ module ViteRails::TagHelpers
|
|
26
26
|
crossorigin: 'anonymous',
|
27
27
|
**options)
|
28
28
|
entries = vite_manifest.resolve_entries(*names, type: asset_type)
|
29
|
-
tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, **options)
|
29
|
+
tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, extname: false, **options)
|
30
30
|
tags << vite_preload_tag(*entries.fetch(:imports), crossorigin: crossorigin) unless skip_preload_tags
|
31
31
|
tags << stylesheet_link_tag(*entries.fetch(:stylesheets)) unless skip_style_tags
|
32
32
|
tags
|
@@ -34,7 +34,7 @@ module ViteRails::TagHelpers
|
|
34
34
|
|
35
35
|
# Public: Renders a <script> tag for the specified Vite entrypoints.
|
36
36
|
def vite_typescript_tag(*names, **options)
|
37
|
-
vite_javascript_tag(*names, asset_type: :typescript,
|
37
|
+
vite_javascript_tag(*names, asset_type: :typescript, **options)
|
38
38
|
end
|
39
39
|
|
40
40
|
# Public: Renders a <link> tag for the specified Vite entrypoints.
|
data/lib/vite_rails/version.rb
CHANGED
@@ -5,6 +5,14 @@
|
|
5
5
|
// <%= vite_javascript_tag 'application' %>
|
6
6
|
console.log('Vite ⚡️ Rails')
|
7
7
|
|
8
|
+
// If using a TypeScript entrypoint file:
|
9
|
+
// <%= vite_typecript_tag 'application.jsx' %>
|
10
|
+
//
|
11
|
+
// If you want to use .jsx or .tsx, add the extension:
|
12
|
+
// <%= vite_javascript_tag 'application.jsx' %>
|
13
|
+
|
14
|
+
console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails')
|
15
|
+
|
8
16
|
// Example: Load Rails libraries in Vite.
|
9
17
|
//
|
10
18
|
// import '@rails/ujs'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vite_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Máximo Mussini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '5.1'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '8'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,76 +27,37 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '5.1'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '8'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: vite_ruby
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
39
|
+
version: '1.0'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.3.0
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
44
|
+
- - "~>"
|
53
45
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
46
|
+
version: '1.0'
|
55
47
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
48
|
+
name: spring
|
57
49
|
requirement: !ruby/object:Gem::Requirement
|
58
50
|
requirements:
|
59
|
-
- - "
|
51
|
+
- - "~>"
|
60
52
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
53
|
+
version: '2.1'
|
62
54
|
type: :development
|
63
55
|
prerelease: false
|
64
56
|
version_requirements: !ruby/object:Gem::Requirement
|
65
57
|
requirements:
|
66
|
-
- - "
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop-minitest
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop-performance
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
58
|
+
- - "~>"
|
95
59
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
60
|
+
version: '2.1'
|
97
61
|
description:
|
98
62
|
email:
|
99
63
|
- maximomussini@gmail.com
|
@@ -102,7 +66,6 @@ extensions: []
|
|
102
66
|
extra_rdoc_files: []
|
103
67
|
files:
|
104
68
|
- CHANGELOG.md
|
105
|
-
- CONTRIBUTING.md
|
106
69
|
- LICENSE.txt
|
107
70
|
- README.md
|
108
71
|
- lib/tasks/vite.rake
|
@@ -118,8 +81,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
118
81
|
licenses:
|
119
82
|
- MIT
|
120
83
|
metadata:
|
121
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@2.0.
|
122
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@2.0.
|
84
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@2.0.6/vite_rails
|
85
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@2.0.6/vite_rails/CHANGELOG.md
|
123
86
|
post_install_message:
|
124
87
|
rdoc_options: []
|
125
88
|
require_paths:
|
data/CONTRIBUTING.md
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
## Setting Up a Development Environment
|
2
|
-
|
3
|
-
1. Install [Yarn](https://yarnpkg.com/)
|
4
|
-
|
5
|
-
2. Run the following commands to set up the development environment.
|
6
|
-
|
7
|
-
```
|
8
|
-
bundle install
|
9
|
-
```
|
10
|
-
|
11
|
-
## Making sure your changes pass all tests
|
12
|
-
There are a number of automated checks which run on GitHub Actions when a pull request is created.
|
13
|
-
You can run those checks on your own locally to make sure that your changes would not break the CI build.
|
14
|
-
|
15
|
-
### 1. Check the code for JavaScript style violations
|
16
|
-
```
|
17
|
-
yarn lint
|
18
|
-
```
|
19
|
-
|
20
|
-
### 2. Check the code for Ruby style violations
|
21
|
-
```
|
22
|
-
bundle exec rubocop
|
23
|
-
```
|
24
|
-
|
25
|
-
### 3. Run the JavaScript test suite
|
26
|
-
```
|
27
|
-
yarn test
|
28
|
-
```
|
29
|
-
|
30
|
-
### 4. Run the Ruby test suite
|
31
|
-
```
|
32
|
-
bundle exec rake test
|
33
|
-
```
|