jekyll-vite 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8d5f8c77007fcdffb37b4767cdd813174bef94133776d8d82bfa5ecec398e67
4
- data.tar.gz: 5a0fb0b03874beb634c8a95c14d608a3ecb7cac70501227672a58f36caab699e
3
+ metadata.gz: '09f74ae904a39710fe2f34f9ec3ff05e66be66ea18367446f90bbd0cbc8bac72'
4
+ data.tar.gz: e4b55188f946f6e954875ca7d18b439f17723765514f5ae017602d8b18e498b1
5
5
  SHA512:
6
- metadata.gz: 3e44cd99b45d1fa61d7b393c24c51ab3ecbcc94dee2107fd61063e5a571b0a2c545195a1c1a2e1fc156550f5e5317894c1c3193e76decbde09430cbb84129a5d
7
- data.tar.gz: c30b269c431a66a5b7ca129d719ed9de7a03f50d3e041d37d447ce16999a40a3b09072d942cc9759f3b008e2a0ac9793b81b8d4417b5f0302b5a75426f2b8842
6
+ metadata.gz: 37cc23bee69476952fbc375f5f9af05a7de2ec3a8d673953cd10078b96a5f04f5a850edbb8c3d241ba4a2052c932271970d46bcaf09a94083ebe3d24d226fe36
7
+ data.tar.gz: 40c5d905b8825b6a62b583c01cd2d2dc1fdcdee2615bc0d3c18257b783a930b8793f95b93053855d105e98252d79835ad1037448bb4e2fee5d26b454fd7e8b86
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## <small>0.0.3 (2021-07-05)</small>
2
+
3
+ * docs: Add documentation site and add test coverage (#1) ([d88f4bb](https://github.com/ElMassimo/vite_ruby/commit/d88f4bb)), closes [#1](https://github.com/ElMassimo/vite_ruby/issues/1)
4
+ * docs: Avoid adding netlify.toml to the final site ([63514c6](https://github.com/ElMassimo/vite_ruby/commit/63514c6))
5
+ * docs: Avoid dark theme flash ([96aea65](https://github.com/ElMassimo/vite_ruby/commit/96aea65))
6
+ * docs: Debug netlify cache ([ab0806e](https://github.com/ElMassimo/vite_ruby/commit/ab0806e))
7
+ * docs: Deploy to netlify (#2) ([efb0683](https://github.com/ElMassimo/vite_ruby/commit/efb0683)), closes [#2](https://github.com/ElMassimo/vite_ruby/issues/2)
8
+
9
+
10
+
1
11
  ## [0.0.2](https://github.com/ElMassimo/vite_ruby/compare/v0.0.1...v0.0.2) (2021-07-03)
2
12
 
3
13
 
data/README.md CHANGED
@@ -1,11 +1,11 @@
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
 
@@ -31,7 +31,7 @@
31
31
  </h1>
32
32
 
33
33
  [vite ruby]: https://github.com/ElMassimo/vite-ruby
34
- [website]: https://vite-ruby.netlify.app/
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,7 @@
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
47
48
 
48
49
  Use [Vite.js] in [Jekyll] and enjoy a modern assets pipeline! ⚡️
49
50
 
@@ -53,7 +54,7 @@ Use [Vite.js] in [Jekyll] and enjoy a modern assets pipeline! ⚡️
53
54
 
54
55
  - ⚡️ Blazing fast hot reload
55
56
  - 📦 Zero-config builds
56
- - 🎨 Use your favorite languages/preprocessors/utilities (TypeScript, Tailwind CSS, etc.)
57
+ - 🎨 Use your favorite tools (TypeScript, Tailwind CSS, etc.)
57
58
 
58
59
  ## Why Vite? 🤔
59
60
 
@@ -66,6 +67,13 @@ a result there is an active ecosystem of plugins and tooling available. In addit
66
67
  it's [no bundling] design provides a very fluid authoring experience—changes to
67
68
  your assets are reflected instantly in your browser.
68
69
 
70
+ ## Documentation 📖
71
+
72
+ The [documentation website][website] is built using `jekyll-vite`.
73
+
74
+ You can [check the source to see an example setup][example], or visit it to
75
+ [learn how to use `jekyll-vite`][website].
76
+
69
77
  ## Installation 💿
70
78
 
71
79
  Add this line to your site's Gemfile:
@@ -81,23 +89,6 @@ bundle install
81
89
  bundle exec vite install
82
90
  ```
83
91
 
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
92
  Additional installation instructions are available in the [documentation website][website].
102
93
 
103
94
  ## Getting Started 💻
@@ -107,9 +98,7 @@ restart your Jekyll server with <kbd>bin/jekyll serve</kbd>.
107
98
 
108
99
  Visit any page and you should see a printed console output: `Vite ⚡️ Ruby`.
109
100
 
110
- For more [guides] and a full [configuration reference], check the [documentation website][website].
111
-
112
- _A new section for Jekyll is coming soon!_
101
+ Check the [documentation website][website] for more information.
113
102
 
114
103
  ## Contact ✉️
115
104
 
@@ -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
@@ -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 = '0.0.3'
6
6
  end
7
7
  end
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: 0.0.3
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-07-05 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/v0.0.2
90
- changelog_uri: https://github.com/ElMassimo/jekyll-vite/blob/v0.0.2/CHANGELOG.md
145
+ source_code_uri: https://github.com/ElMassimo/jekyll-vite/tree/v0.0.3
146
+ changelog_uri: https://github.com/ElMassimo/jekyll-vite/blob/v0.0.3/CHANGELOG.md
91
147
  post_install_message:
92
148
  rdoc_options: []
93
149
  require_paths: