vite_plugin_legacy 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ad345c925498e8538f59aa3868f0f406fc47883e490e4878126a810789696a0f
4
+ data.tar.gz: 9761f17774c82641a7d457425965d3d49708b18e493a1041dd1211fa0ff79a09
5
+ SHA512:
6
+ metadata.gz: 6b9c7fceac3b94cba30107f5c7fd8dc3be280c3a4b2239659d0b17e35b2097b876a9a7d97a492379190c35ee899bd4b3ca73918256732c5d8f29b19b080d91da
7
+ data.tar.gz: c007c55df8183531e85fe92b126088b03d64478550284279fd25ca45a28959d49dd5e49ca28d3b1ddb8c3d883755d6bead72e0db03a0c470751d439de265a595
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # 0.5.0 (2021-03-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add vite_plugin_legacy with tag helpers for @vitejs/plugin-legacy ([#28](https://github.com/ElMassimo/vite_ruby/issues/28)) ([03ee431](https://github.com/ElMassimo/vite_ruby/commit/03ee431ede482474896d2ab48146758ca24e2bf6))
7
+
8
+
9
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Maximo Mussini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ <h1 align="center">
2
+ <a href="https://vite-ruby.netlify.app/">
3
+ <img src="https://raw.githubusercontent.com/ElMassimo/vite_ruby/main/docs/public/logo.svg" width="120px"/>
4
+ </a>
5
+
6
+ <br>
7
+
8
+ <a href="https://vite-ruby.netlify.app/">
9
+ Tag Helpers for <kbd>@vitejs/plugin-legacy</kbd>
10
+ </a>
11
+
12
+ <br>
13
+
14
+ <p align="center">
15
+ <a href="https://github.com/ElMassimo/vite_ruby/actions">
16
+ <img alt="Build Status" src="https://github.com/ElMassimo/vite_ruby/workflows/build/badge.svg"/>
17
+ </a>
18
+ <a href="https://codeclimate.com/github/ElMassimo/vite_ruby">
19
+ <img alt="Maintainability" src="https://codeclimate.com/github/ElMassimo/vite_ruby/badges/gpa.svg"/>
20
+ </a>
21
+ <a href="https://codeclimate.com/github/ElMassimo/vite_ruby">
22
+ <img alt="Test Coverage" src="https://codeclimate.com/github/ElMassimo/vite_ruby/badges/coverage.svg"/>
23
+ </a>
24
+ <a href="https://rubygems.org/gems/vite_plugin_legacy">
25
+ <img alt="Gem Version" src="https://img.shields.io/gem/v/vite_plugin_legacy.svg?colorB=e9573f"/>
26
+ </a>
27
+ <a href="https://github.com/ElMassimo/vite_ruby/blob/master/LICENSE.txt">
28
+ <img alt="License" src="https://img.shields.io/badge/license-MIT-428F7E.svg"/>
29
+ </a>
30
+ </p>
31
+ </h1>
32
+
33
+ [vite_ruby]: https://github.com/ElMassimo/vite_ruby/tree/main/vite_ruby
34
+ [website]: https://vite-ruby.netlify.app/guide/plugin-legacy
35
+ [plugin-legacy]: https://github.com/vitejs/vite/tree/main/packages/plugin-legacy
36
+
37
+ __Vite Plugin Legacy__ provides tag helpers to output assets generated by [`@vitejs/plugin-legacy`][plugin-legacy].
38
+
39
+ ## Installation 💿
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'vite_plugin_legacy'
45
+ ```
46
+
47
+ Then, run:
48
+
49
+ ```bash
50
+ bundle install
51
+ ```
52
+
53
+ Additional installation instructions are available in the [documentation website][website].
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vite_ruby'
4
+
5
+ require 'vite_plugin_legacy/version'
6
+ require 'vite_plugin_legacy/tag_helpers'
7
+ require 'vite_plugin_legacy/engine' if defined?(Rails)
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vite_rails'
4
+ require 'rails/railtie'
5
+
6
+ class VitePluginLegacy::Engine < Rails::Engine
7
+ initializer 'vite_plugin_legacy.helper' do
8
+ ActiveSupport.on_load(:action_controller) do
9
+ ActionController::Base.helper(VitePluginLegacy::TagHelpers)
10
+ end
11
+
12
+ ActiveSupport.on_load(:action_view) do
13
+ include VitePluginLegacy::TagHelpers
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Public: Allows to render HTML tags for scripts and styles processed by Vite.
4
+ module VitePluginLegacy::TagHelpers
5
+ # Public: Renders a <script> tag for the specified Vite entrypoints when using
6
+ # @vitejs/plugin-legacy, which injects polyfills.
7
+ def vite_legacy_javascript_tag(name, asset_type: :javascript)
8
+ return if ViteRuby.instance.dev_server_running?
9
+
10
+ legacy_name = name.sub(/\.|$/, '-legacy\1')
11
+ id = "vite-#{ legacy_name.tr(' .\'', '-') }-entry"
12
+ import_tag = content_tag(:script, nomodule: false, id: id, 'data-src': vite_asset_path(legacy_name, type: asset_type)) {
13
+ "System.import(document.getElementById('#{ id }').getAttribute('data-src'))".html_safe
14
+ }
15
+
16
+ safe_join [vite_legacy_polyfill_tag, import_tag]
17
+ end
18
+
19
+ # Internal: Renders the vite-legacy-polyfill to enable code splitting in
20
+ # browsers that do not support modules.
21
+ def vite_legacy_polyfill_tag
22
+ return if ViteRuby.instance.dev_server_running?
23
+
24
+ name = vite_manifest.send(:manifest).keys.find { |file| file.include?('legacy-polyfills') } ||
25
+ raise(ArgumentError, 'Vite legacy polyfill not found in manifest.json')
26
+ content_tag(:script, nil, nomodule: false, src: vite_asset_path(name))
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VitePluginLegacy
4
+ VERSION = '0.5.0'
5
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vite_plugin_legacy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Máximo Mussini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: vite_ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
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
+ description:
84
+ email:
85
+ - maximomussini@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - CHANGELOG.md
91
+ - LICENSE.txt
92
+ - README.md
93
+ - lib/vite_plugin_legacy.rb
94
+ - lib/vite_plugin_legacy/engine.rb
95
+ - lib/vite_plugin_legacy/tag_helpers.rb
96
+ - lib/vite_plugin_legacy/version.rb
97
+ homepage: https://github.com/ElMassimo/vite_ruby
98
+ licenses:
99
+ - MIT
100
+ metadata:
101
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_plugin_legacy@0.5.0/vite_plugin_legacy
102
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_plugin_legacy@0.5.0/vite_plugin_legacy/CHANGELOG.md
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '2.5'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.1.4
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Tag helpers for @vitejs/plugin-legacy to support legacy browsers
122
+ test_files: []