jekyll-vite 0.0.1 → 1.0.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 +4 -4
- data/CHANGELOG.md +38 -7
- data/README.md +19 -38
- data/lib/jekyll/vite/config.rb +3 -3
- data/lib/jekyll/vite/generator.rb +25 -7
- data/lib/jekyll/vite/installation.rb +7 -1
- data/lib/jekyll/vite/proxy.rb +5 -3
- data/lib/jekyll/vite/tags.rb +14 -2
- data/lib/jekyll/vite/version.rb +1 -1
- data/templates/config/jekyll-vite.json +1 -1
- metadata +60 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6687f3165b7bd34011b9d488746cdb5b998a091ec106fe20bc6ec25534861e8
|
4
|
+
data.tar.gz: fe3e88c00738f30d4fde3637a658cf4d617b4dfb4a625d6b5280229ed59452bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf7a8c2a00fb7f46cf14c0574adaa8d84e0d6a72433b838703e11d18519a7255841502712a594d3e0aacf34f88c4197f804fb254a3363d26aa1c95bae4061d8c
|
7
|
+
data.tar.gz: 24eadaa85832157190f81fece490f8907dbe5f59c14ec4234672da6010dd762b8327d8b478ae6814edece0b73b7834cdb2322148697bc38168ac3867a873ba41
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,45 @@
|
|
1
|
+
# [1.0.0](https://github.com/ElMassimo/jekyll-vite/compare/v0.0.3...v1.0.0) (2021-07-22)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* Watch layouts and partials by default ([004e8f1](https://github.com/ElMassimo/jekyll-vite/commit/004e8f1318fda3031a7ea8ebbd6b396e742b7642))
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
## [0.0.3](https://github.com/ElMassimo/jekyll-vite/compare/v0.0.2...v0.0.3) (2021-07-05)
|
11
|
+
|
12
|
+
### Features
|
13
|
+
|
14
|
+
- Add support for Jekyll 3.9
|
15
|
+
- Add `vite_react_refresh_tag` helper
|
16
|
+
|
17
|
+
### Bug Fixes
|
18
|
+
|
19
|
+
- Ensure non-proxied requests are served with an HTTP status
|
20
|
+
- Ensure Ruby 3.0 support
|
21
|
+
|
22
|
+
|
23
|
+
## [0.0.2](https://github.com/ElMassimo/jekyll-vite/compare/v0.0.1...v0.0.2) (2021-07-03)
|
24
|
+
|
25
|
+
|
26
|
+
### Bug Fixes
|
27
|
+
|
28
|
+
* Do not serve files with custom status in local development server ([86cf47b](https://github.com/ElMassimo/jekyll-vite/commit/86cf47b485520879c7b7e7a79c7245dc0ba92b16))
|
29
|
+
|
30
|
+
|
31
|
+
|
1
32
|
## 0.0.1 (2021-07-02)
|
2
33
|
|
3
34
|
### Features
|
4
35
|
|
5
|
-
* Build vite assets when generating site and preserve assets correctly ([0b9a138](https://github.com/ElMassimo/
|
6
|
-
* Ignore Vite dir when the dev server is active, add the last build ([548a47f](https://github.com/ElMassimo/
|
7
|
-
* Implement a WEBrick proxy servlet for Jekyll ([b5afe03](https://github.com/ElMassimo/
|
8
|
-
* Implement liquid tags to render script and stylesheet tags ([4cbb679](https://github.com/ElMassimo/
|
9
|
-
* Read mode from JEKYLL_ENV ([acd7181](https://github.com/ElMassimo/
|
10
|
-
* Serve files from the cache when the Vite dev server is down ([d695718](https://github.com/ElMassimo/
|
11
|
-
* Track dependencies on entrypoints ([5b8c413](https://github.com/ElMassimo/
|
36
|
+
* Build vite assets when generating site and preserve assets correctly ([0b9a138](https://github.com/ElMassimo/jekyll-vite/commit/0b9a138393a00c96119e42d5a59ac71539d00912))
|
37
|
+
* Ignore Vite dir when the dev server is active, add the last build ([548a47f](https://github.com/ElMassimo/jekyll-vite/commit/548a47f8bbb6f22820083d22d4628d445149ba46))
|
38
|
+
* Implement a WEBrick proxy servlet for Jekyll ([b5afe03](https://github.com/ElMassimo/jekyll-vite/commit/b5afe03b763235c23d9eaf940086d6ddb19399dc))
|
39
|
+
* Implement liquid tags to render script and stylesheet tags ([4cbb679](https://github.com/ElMassimo/jekyll-vite/commit/4cbb679af2625f31954c56b7cda032c896d7e127))
|
40
|
+
* Read mode from JEKYLL_ENV ([acd7181](https://github.com/ElMassimo/jekyll-vite/commit/acd7181c507cd1971f056462f240dec0071acf3b))
|
41
|
+
* Serve files from the cache when the Vite dev server is down ([d695718](https://github.com/ElMassimo/jekyll-vite/commit/d695718b1805211aa8b63c81d140b7212d2347f5))
|
42
|
+
* Track dependencies on entrypoints ([5b8c413](https://github.com/ElMassimo/jekyll-vite/commit/5b8c41336085e24568750bcbc77192f498488f46))
|
12
43
|
|
13
44
|
|
14
45
|
|
data/README.md
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
<h1 align="center">
|
2
|
-
<a href="https://vite
|
2
|
+
<a href="https://jekyll-vite.netlify.app/">
|
3
3
|
<img src="https://raw.githubusercontent.com/ElMassimo/vite_ruby/main/docs/public/logo.svg" width="120px"/>
|
4
4
|
</a>
|
5
5
|
|
6
6
|
<br>
|
7
7
|
|
8
|
-
<a href="https://vite
|
8
|
+
<a href="https://jekyll-vite.netlify.app/">
|
9
9
|
Jekyll ➕ Vite.js
|
10
10
|
</a>
|
11
11
|
|
12
12
|
<br>
|
13
13
|
|
14
14
|
<p align="center">
|
15
|
-
|
15
|
+
<a href="https://github.com/ElMassimo/jekyll-vite/actions">
|
16
16
|
<img alt="Build Status" src="https://github.com/ElMassimo/jekyll-vite/workflows/build/badge.svg"/>
|
17
|
-
</a>
|
18
|
-
|
17
|
+
</a>
|
18
|
+
<a href="https://codeclimate.com/github/ElMassimo/jekyll-vite">
|
19
19
|
<img alt="Maintainability" src="https://codeclimate.com/github/ElMassimo/jekyll-vite/badges/gpa.svg"/>
|
20
20
|
</a>
|
21
21
|
<a href="https://codeclimate.com/github/ElMassimo/jekyll-vite">
|
22
|
-
<img alt="Test Coverage" src="https://codeclimate.com/github/ElMassimo/jekyll-vite/badges/coverage.svg"/>
|
22
|
+
<img alt="Test Coverage" src="https://codeclimate.com/github/ElMassimo/jekyll-vite/badges/coverage.svg"/>
|
23
23
|
</a>
|
24
24
|
<a href="https://rubygems.org/gems/jekyll-vite">
|
25
25
|
<img alt="Gem Version" src="https://img.shields.io/gem/v/jekyll-vite.svg?colorB=e9573f"/>
|
@@ -30,8 +30,8 @@
|
|
30
30
|
</p>
|
31
31
|
</h1>
|
32
32
|
|
33
|
-
[
|
34
|
-
[website]: https://vite
|
33
|
+
[vite ruby]: https://github.com/ElMassimo/vite_ruby
|
34
|
+
[website]: https://jekyll-vite.netlify.app/
|
35
35
|
[jekyll]: https://jekyllrb.com/
|
36
36
|
[configuration reference]: https://vite-ruby.netlify.app/config/
|
37
37
|
[features]: https://vite-ruby.netlify.app/guide/introduction.html
|
@@ -44,6 +44,8 @@
|
|
44
44
|
[bundling]: https://vitejs.dev/guide/why.html#why-bundle-for-production
|
45
45
|
[rollup.js]: https://rollupjs.org
|
46
46
|
[esbuild]: https://esbuild.github.io/
|
47
|
+
[example]: https://github.com/ElMassimo/jekyll-vite/tree/main/docs
|
48
|
+
[installation]: https://jekyll-vite.netlify.app/posts/installation/
|
47
49
|
|
48
50
|
Use [Vite.js] in [Jekyll] and enjoy a modern assets pipeline! ⚡️
|
49
51
|
|
@@ -53,7 +55,7 @@ Use [Vite.js] in [Jekyll] and enjoy a modern assets pipeline! ⚡️
|
|
53
55
|
|
54
56
|
- ⚡️ Blazing fast hot reload
|
55
57
|
- 📦 Zero-config builds
|
56
|
-
- 🎨 Use your favorite
|
58
|
+
- 🎨 Use your favorite tools (TypeScript, Tailwind CSS, etc.)
|
57
59
|
|
58
60
|
## Why Vite? 🤔
|
59
61
|
|
@@ -66,6 +68,13 @@ a result there is an active ecosystem of plugins and tooling available. In addit
|
|
66
68
|
it's [no bundling] design provides a very fluid authoring experience—changes to
|
67
69
|
your assets are reflected instantly in your browser.
|
68
70
|
|
71
|
+
## Documentation 📖
|
72
|
+
|
73
|
+
The [documentation website][website] is built using `jekyll-vite`.
|
74
|
+
|
75
|
+
You can [check the source to see an example setup][example], or visit it to
|
76
|
+
[learn how to use `jekyll-vite`][website].
|
77
|
+
|
69
78
|
## Installation 💿
|
70
79
|
|
71
80
|
Add this line to your site's Gemfile:
|
@@ -81,35 +90,7 @@ bundle install
|
|
81
90
|
bundle exec vite install
|
82
91
|
```
|
83
92
|
|
84
|
-
|
85
|
-
`_layouts/default.html` (if it exists).
|
86
|
-
|
87
|
-
```yml
|
88
|
-
plugins:
|
89
|
-
- jekyll/vite
|
90
|
-
```
|
91
|
-
|
92
|
-
```html
|
93
|
-
<head>
|
94
|
-
<!-- meta tags, etc -->
|
95
|
-
{% vite_client_tag %}
|
96
|
-
{% vite_javascript_tag application %}
|
97
|
-
{% vite_stylesheet_tag styles.scss %}
|
98
|
-
</head>
|
99
|
-
```
|
100
|
-
|
101
|
-
Additional installation instructions are available in the [documentation website][website].
|
102
|
-
|
103
|
-
## Getting Started 💻
|
104
|
-
|
105
|
-
Run <kbd>bin/vite dev</kbd> to start the Vite development server, and then
|
106
|
-
restart your Jekyll server with <kbd>bin/jekyll serve</kbd>.
|
107
|
-
|
108
|
-
Visit any page and you should see a printed console output: `Vite ⚡️ Ruby`.
|
109
|
-
|
110
|
-
For more [guides] and a full [configuration reference], check the [documentation website][website].
|
111
|
-
|
112
|
-
_A new section for Jekyll is coming soon!_
|
93
|
+
Additional [installation instructions][installation] are available in the [documentation website][installation].
|
113
94
|
|
114
95
|
## Contact ✉️
|
115
96
|
|
data/lib/jekyll/vite/config.rb
CHANGED
@@ -4,10 +4,10 @@ module Jekyll::Vite::Config
|
|
4
4
|
# Override: Provide default values for a typical Jekyll site.
|
5
5
|
def config_defaults(**opts)
|
6
6
|
require 'jekyll'
|
7
|
-
|
7
|
+
cache_dir = Jekyll.configuration['cache_dir'] || '.jekyll-cache'
|
8
8
|
super(**opts, mode: Jekyll.env).tap do |defaults|
|
9
|
-
defaults['public_dir'] =
|
10
|
-
defaults['build_cache_dir'] = File.join(
|
9
|
+
defaults['public_dir'] = cache_dir
|
10
|
+
defaults['build_cache_dir'] = File.join(cache_dir, 'vite-build')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -7,9 +7,22 @@ class Jekyll::Vite::Generator < Jekyll::Generator
|
|
7
7
|
priority :highest
|
8
8
|
|
9
9
|
class ViteAssetFile < Jekyll::StaticFile
|
10
|
+
# Override (4.2): Copy to the configured public_output_dir
|
11
|
+
if method_defined?(:cleaned_relative_path)
|
12
|
+
def cleaned_relative_path
|
13
|
+
replace_build_path(super)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
# Override: Copy to the configured public_output_dir
|
11
|
-
def
|
12
|
-
super
|
18
|
+
def destination_rel_dir
|
19
|
+
replace_build_path(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def replace_build_path(src)
|
25
|
+
src.sub(
|
13
26
|
ViteRuby.config.build_output_dir.relative_path_from(@site.source).to_s,
|
14
27
|
ViteRuby.config.public_output_dir,
|
15
28
|
)
|
@@ -27,12 +40,17 @@ class Jekyll::Vite::Generator < Jekyll::Generator
|
|
27
40
|
# Internal: Build all assets with Vite and add them to the site's static files.
|
28
41
|
def generate_vite_build(site)
|
29
42
|
ViteRuby.commands.build_from_task
|
30
|
-
|
31
|
-
|
43
|
+
add_static_files(site, ViteRuby.config.build_output_dir)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Internal: Add generated assets to the site's static files.
|
47
|
+
def add_static_files(site, assets_dir)
|
48
|
+
relative_assets_dir = assets_dir.relative_path_from(site.source).to_s
|
49
|
+
vite_static_files = Dir.chdir(assets_dir.to_s) {
|
32
50
|
Dir.glob('**/*').select { |f| File.file?(f) }
|
51
|
+
}.map { |file|
|
52
|
+
ViteAssetFile.new(site, site.source, relative_assets_dir, file)
|
33
53
|
}
|
34
|
-
site.static_files.concat(
|
35
|
-
ViteAssetFile.new(site, site.source, assets_dir, file)
|
36
|
-
})
|
54
|
+
site.static_files.concat(vite_static_files)
|
37
55
|
end
|
38
56
|
end
|
@@ -19,7 +19,13 @@ module Jekyll::Vite::Installation
|
|
19
19
|
# Override: Inject the vite client and sample script to the default HTML template.
|
20
20
|
def install_sample_files
|
21
21
|
super
|
22
|
-
|
22
|
+
inject_line_after_last root.join('_config.yml'), 'plugins:', ' - jekyll/vite'
|
23
|
+
inject_line_after_last root.join('_config.yml'), 'exclude:', <<-YML.chomp("\n")
|
24
|
+
- bin
|
25
|
+
- config
|
26
|
+
- vite.config.ts
|
27
|
+
- tmp
|
28
|
+
YML
|
23
29
|
inject_line_before root.join('_layouts/default.html'), '</head>', <<-HTML.chomp("\n")
|
24
30
|
{% vite_client_tag %}
|
25
31
|
{% vite_javascript_tag application %}
|
data/lib/jekyll/vite/proxy.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rack'
|
4
|
-
require 'webrick'
|
5
4
|
require 'jekyll/commands/serve/servlet'
|
6
5
|
|
7
6
|
# Internal: Extend the default servlet to add a Rack-based proxy in order to
|
8
7
|
# forward asset requests to the Vite.js development server.
|
9
8
|
module Jekyll::Vite::Proxy
|
10
9
|
# Internal: Used to detect proxied requests since it's not a valid status code.
|
11
|
-
STATUS_SERVE_ORIGINAL =
|
10
|
+
STATUS_SERVE_ORIGINAL = 7
|
12
11
|
|
13
12
|
def initialize(server, *args)
|
14
13
|
@server = server
|
@@ -28,7 +27,10 @@ module Jekyll::Vite::Proxy
|
|
28
27
|
# default Jekyll response instead.
|
29
28
|
def service(req, res)
|
30
29
|
proxy_servlet.service(req, res)
|
31
|
-
|
30
|
+
if res.status == STATUS_SERVE_ORIGINAL
|
31
|
+
res.status = 200
|
32
|
+
super
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
private
|
data/lib/jekyll/vite/tags.rb
CHANGED
@@ -64,7 +64,7 @@ protected
|
|
64
64
|
['', '.css', '.js', '.ts'].each do |ext|
|
65
65
|
if File.file?(asset_path = "#{ path }#{ ext }")
|
66
66
|
return [asset_path, last_build_metadata_path].each do |filename|
|
67
|
-
add_include_to_dependency(site, filename, @context)
|
67
|
+
add_include_to_dependency(site, filename.to_s, @context)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -80,7 +80,7 @@ end
|
|
80
80
|
# Public: Renders a path to a Vite asset.
|
81
81
|
class Jekyll::Vite::AssetPathTag < Jekyll::Vite::Tag
|
82
82
|
def render(context)
|
83
|
-
super { vite_asset_path(@file,
|
83
|
+
super { vite_asset_path(@file, **@params) }
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -99,6 +99,17 @@ class Jekyll::Vite::ClientTag < Jekyll::Vite::Tag
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
# Public: Renders a script tag to enable HMR with React Refresh.
|
103
|
+
class Jekyll::Vite::ReactRefreshTag < Jekyll::Vite::Tag
|
104
|
+
def render(_context)
|
105
|
+
vite_manifest.react_refresh_preamble&.html_safe
|
106
|
+
end
|
107
|
+
|
108
|
+
def syntax_example
|
109
|
+
"{% #{ @tag_name } %}"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
102
113
|
# Public: Renders a <link> tag for the specified stylesheet.
|
103
114
|
class Jekyll::Vite::StylesheetTag < Jekyll::Vite::Tag
|
104
115
|
def render(context)
|
@@ -149,6 +160,7 @@ end
|
|
149
160
|
'vite_javascript_tag' => Jekyll::Vite::JavascriptTag,
|
150
161
|
'vite_typescript_tag' => Jekyll::Vite::JavascriptTag,
|
151
162
|
'vite_stylesheet_tag' => Jekyll::Vite::StylesheetTag,
|
163
|
+
'vite_react_refresh_tag' => Jekyll::Vite::ReactRefreshTag,
|
152
164
|
}.each do |name, tag|
|
153
165
|
Liquid::Template.register_tag(name, tag)
|
154
166
|
end
|
data/lib/jekyll/vite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-vite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
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-07-
|
11
|
+
date: 2021-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '2'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: pry-byebug
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: rake
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +78,48 @@ dependencies:
|
|
64
78
|
- - ">="
|
65
79
|
- !ruby/object:Gem::Version
|
66
80
|
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: simplecov
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "<"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.18'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0.18'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: webrick
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
67
123
|
description:
|
68
124
|
email:
|
69
125
|
- maximomussini@gmail.com
|
@@ -86,8 +142,8 @@ homepage: https://github.com/ElMassimo/jekyll-vite
|
|
86
142
|
licenses:
|
87
143
|
- MIT
|
88
144
|
metadata:
|
89
|
-
source_code_uri: https://github.com/ElMassimo/jekyll-vite/tree/
|
90
|
-
changelog_uri: https://github.com/ElMassimo/jekyll-vite/blob/
|
145
|
+
source_code_uri: https://github.com/ElMassimo/jekyll-vite/tree/v1.0.1
|
146
|
+
changelog_uri: https://github.com/ElMassimo/jekyll-vite/blob/v1.0.1/CHANGELOG.md
|
91
147
|
post_install_message:
|
92
148
|
rdoc_options: []
|
93
149
|
require_paths:
|