jekyll-vite 0.0.2 → 2.0.0.beta.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: f8d5f8c77007fcdffb37b4767cdd813174bef94133776d8d82bfa5ecec398e67
4
- data.tar.gz: 5a0fb0b03874beb634c8a95c14d608a3ecb7cac70501227672a58f36caab699e
3
+ metadata.gz: 56c3e622bea10cfa0ed069d465fbcba7ff6ac5bdffb9df9a5fc416a6e6137f12
4
+ data.tar.gz: 69d35f0dcf8e46604c709d41c9052225dfc36beddc698e304dd3c4a701ca6aee
5
5
  SHA512:
6
- metadata.gz: 3e44cd99b45d1fa61d7b393c24c51ab3ecbcc94dee2107fd61063e5a571b0a2c545195a1c1a2e1fc156550f5e5317894c1c3193e76decbde09430cbb84129a5d
7
- data.tar.gz: c30b269c431a66a5b7ca129d719ed9de7a03f50d3e041d37d447ce16999a40a3b09072d942cc9759f3b008e2a0ac9793b81b8d4417b5f0302b5a75426f2b8842
6
+ metadata.gz: e71487337973282dacb4a736bda265332c10db7b25f0579ffc5dfaf62fffb8c91c3a18378476b4937f583273ac556e9b78a9534859d373725c0cb900c8f3447c
7
+ data.tar.gz: 4d995e5292a475307a061ab4da50e697c25d81b7934a3e2cac50118efd371b869ae382c77266306b3b41031cc4ede67b7e8790492cbbeb80f74d3c25fffc1031
data/CHANGELOG.md CHANGED
@@ -1,9 +1,31 @@
1
- ## [0.0.2](https://github.com/ElMassimo/vite_ruby/compare/v0.0.1...v0.0.2) (2021-07-03)
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)
2
24
 
3
25
 
4
26
  ### Bug Fixes
5
27
 
6
- * Do not serve files with custom status in local development server ([86cf47b](https://github.com/ElMassimo/vite_ruby/commit/86cf47b485520879c7b7e7a79c7245dc0ba92b16))
28
+ * Do not serve files with custom status in local development server ([86cf47b](https://github.com/ElMassimo/jekyll-vite/commit/86cf47b485520879c7b7e7a79c7245dc0ba92b16))
7
29
 
8
30
 
9
31
 
@@ -11,13 +33,13 @@
11
33
 
12
34
  ### Features
13
35
 
14
- * Build vite assets when generating site and preserve assets correctly ([0b9a138](https://github.com/ElMassimo/vite_ruby/commit/0b9a138393a00c96119e42d5a59ac71539d00912))
15
- * Ignore Vite dir when the dev server is active, add the last build ([548a47f](https://github.com/ElMassimo/vite_ruby/commit/548a47f8bbb6f22820083d22d4628d445149ba46))
16
- * Implement a WEBrick proxy servlet for Jekyll ([b5afe03](https://github.com/ElMassimo/vite_ruby/commit/b5afe03b763235c23d9eaf940086d6ddb19399dc))
17
- * Implement liquid tags to render script and stylesheet tags ([4cbb679](https://github.com/ElMassimo/vite_ruby/commit/4cbb679af2625f31954c56b7cda032c896d7e127))
18
- * Read mode from JEKYLL_ENV ([acd7181](https://github.com/ElMassimo/vite_ruby/commit/acd7181c507cd1971f056462f240dec0071acf3b))
19
- * Serve files from the cache when the Vite dev server is down ([d695718](https://github.com/ElMassimo/vite_ruby/commit/d695718b1805211aa8b63c81d140b7212d2347f5))
20
- * Track dependencies on entrypoints ([5b8c413](https://github.com/ElMassimo/vite_ruby/commit/5b8c41336085e24568750bcbc77192f498488f46))
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))
21
43
 
22
44
 
23
45
 
data/README.md CHANGED
@@ -1,25 +1,25 @@
1
1
  <h1 align="center">
2
- <a href="https://vite-ruby.netlify.app/">
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-ruby.netlify.app/">
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
- <!-- <a href="https://github.com/ElMassimo/jekyll-vite/actions">
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
- <!-- <a href="https://codeclimate.com/github/ElMassimo/jekyll-vite">
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
- [vite ruby]: https://github.com/ElMassimo/vite-ruby
34
- [website]: https://vite-ruby.netlify.app/
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 languages/preprocessors/utilities (TypeScript, Tailwind CSS, etc.)
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
- This will install the plugin in `_config.yml`, and generate a sample setup in
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
 
@@ -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
- config = Jekyll.configuration
7
+ cache_dir = Jekyll.configuration['cache_dir'] || '.jekyll-cache'
8
8
  super(**opts, mode: Jekyll.env).tap do |defaults|
9
- defaults['public_dir'] = config['cache_dir']
10
- defaults['build_cache_dir'] = File.join(config['cache_dir'], 'vite-build')
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 cleaned_relative_path
12
- super.sub(
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
- assets_dir = ViteRuby.config.build_output_dir.relative_path_from(site.source)
31
- files = Dir.chdir(ViteRuby.config.build_output_dir.to_s) {
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(files.map { |file|
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
- inject_line_after root.join('_config.yml'), 'plugins:', ' - jekyll/vite'
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 %}
@@ -1,7 +1,6 @@
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
@@ -29,7 +28,7 @@ module Jekyll::Vite::Proxy
29
28
  def service(req, res)
30
29
  proxy_servlet.service(req, res)
31
30
  if res.status == STATUS_SERVE_ORIGINAL
32
- res.status = nil
31
+ res.status = 200
33
32
  super
34
33
  end
35
34
  end
@@ -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, @params) }
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Vite
5
- VERSION = '0.0.2'
5
+ VERSION = '2.0.0.beta.1'
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "all": {
3
3
  "sourceCodeDir": "_frontend",
4
- "watchAdditionalPaths": []
4
+ "watchAdditionalPaths": ["index.html", "_includes/**/*", "_layouts/**/*"]
5
5
  },
6
6
  "development": {
7
7
  "autoBuild": true,
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: 0.0.2
4
+ version: 2.0.0.beta.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-03 00:00:00.000000000 Z
11
+ date: 2021-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -32,26 +32,76 @@ dependencies:
32
32
  version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: vite_ruby
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 2.0.0.beta.3
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 2.0.0.beta.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: pry-byebug
35
49
  requirement: !ruby/object:Gem::Requirement
36
50
  requirements:
37
51
  - - ">="
38
52
  - !ruby/object:Gem::Version
39
- version: 1.2.14
40
- - - "<"
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
41
59
  - !ruby/object:Gem::Version
42
- version: '2'
43
- type: :runtime
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
44
69
  prerelease: false
45
70
  version_requirements: !ruby/object:Gem::Requirement
46
71
  requirements:
47
72
  - - ">="
48
73
  - !ruby/object:Gem::Version
49
- version: 1.2.14
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: simplecov
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.18'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
50
100
  - - "<"
51
101
  - !ruby/object:Gem::Version
52
- version: '2'
102
+ version: '0.18'
53
103
  - !ruby/object:Gem::Dependency
54
- name: rake
104
+ name: webrick
55
105
  requirement: !ruby/object:Gem::Requirement
56
106
  requirements:
57
107
  - - ">="
@@ -86,8 +136,8 @@ homepage: https://github.com/ElMassimo/jekyll-vite
86
136
  licenses:
87
137
  - MIT
88
138
  metadata:
89
- source_code_uri: https://github.com/ElMassimo/jekyll-vite/tree/v0.0.2
90
- changelog_uri: https://github.com/ElMassimo/jekyll-vite/blob/v0.0.2/CHANGELOG.md
139
+ source_code_uri: https://github.com/ElMassimo/jekyll-vite/tree/v2.0.0.beta.1
140
+ changelog_uri: https://github.com/ElMassimo/jekyll-vite/blob/v2.0.0.beta.1/CHANGELOG.md
91
141
  post_install_message:
92
142
  rdoc_options: []
93
143
  require_paths:
@@ -99,9 +149,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
149
  version: '2.4'
100
150
  required_rubygems_version: !ruby/object:Gem::Requirement
101
151
  requirements:
102
- - - ">="
152
+ - - ">"
103
153
  - !ruby/object:Gem::Version
104
- version: '0'
154
+ version: 1.3.1
105
155
  requirements: []
106
156
  rubygems_version: 3.1.4
107
157
  signing_key: