jekyll-webpack 0.2.5 → 0.2.7

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: 607c1063222b8746e6e1a90de9a5272e41895beba7672c72e8b9742823593412
4
- data.tar.gz: e141cb8fcb480ef152b731554ba4fef8cee98bf8b4263f4f7d0a4ccc06630cfc
3
+ metadata.gz: 9e283de4d72f04e0ac364a5f0c5756a45aedfcbbbdec766629cd2bc329acbd03
4
+ data.tar.gz: 6e729e813d0b960a4b3f29187c891d28e3f5add025f9385364c57a33241dd39e
5
5
  SHA512:
6
- metadata.gz: cf664c9e5c38e781ab700c92aa725ed93b74dd62d7fa5fcf94cfb2211e9b8595bfe19d4dd1ff4252d13bd1310dd0dd8711db9cf006c5ba6939944aae89c12fd9
7
- data.tar.gz: 04fc1d4d20fa4ed5290a596658e56a70e2873cbd6f8f0abf2740ff964960b547c2803aeea277139cbfd945843b312442e20fa47f20df8460293b055255802fd7
6
+ metadata.gz: 7221b24f125a01643575a8911ce2d126b314482a97a71c82db69f9faad9f842ff6d52df6645f872ef812afebff570ad6cf84a0307114f35dbba972fc7d573c4f
7
+ data.tar.gz: 9625df1e171146aabde6a70972c2947a9fbf84cc67dc6b24a7fba9ffa0966f9bea08704e51d27f8749af5c60b10fae4e60ec54c738e72a631de0017d875dafb7
data/.gitignore CHANGED
@@ -15,3 +15,4 @@
15
15
  # rspec failure tracking
16
16
  .rspec_status
17
17
  tags
18
+ .ruby-version
data/Gemfile.lock CHANGED
@@ -1,26 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-webpack (0.2.3)
4
+ jekyll-webpack (0.2.7)
5
5
  jekyll
6
+ listen
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- addressable (2.8.0)
11
- public_suffix (>= 2.0.2, < 5.0)
11
+ addressable (2.8.5)
12
+ public_suffix (>= 2.0.2, < 6.0)
12
13
  coderay (1.1.3)
13
14
  colorator (1.1.0)
14
- concurrent-ruby (1.1.9)
15
- diff-lcs (1.4.4)
16
- em-websocket (0.5.2)
15
+ concurrent-ruby (1.2.2)
16
+ diff-lcs (1.5.0)
17
+ em-websocket (0.5.3)
17
18
  eventmachine (>= 0.12.9)
18
- http_parser.rb (~> 0.6.0)
19
+ http_parser.rb (~> 0)
19
20
  eventmachine (1.2.7)
20
- ffi (1.15.3)
21
- formatador (0.3.0)
21
+ ffi (1.16.3)
22
+ formatador (1.1.0)
22
23
  forwardable-extended (2.6.0)
23
- guard (2.18.0)
24
+ google-protobuf (3.25.1-arm64-darwin)
25
+ guard (2.18.1)
24
26
  formatador (>= 0.2.4)
25
27
  listen (>= 2.7, < 4.0)
26
28
  lumberjack (>= 1.0.12, < 2.0)
@@ -34,37 +36,38 @@ GEM
34
36
  guard (~> 2.1)
35
37
  guard-compat (~> 1.1)
36
38
  rspec (>= 2.99.0, < 4.0)
37
- http_parser.rb (0.6.0)
38
- i18n (1.8.10)
39
+ http_parser.rb (0.8.0)
40
+ i18n (1.14.1)
39
41
  concurrent-ruby (~> 1.0)
40
- jekyll (4.2.0)
42
+ jekyll (4.3.2)
41
43
  addressable (~> 2.4)
42
44
  colorator (~> 1.0)
43
45
  em-websocket (~> 0.5)
44
46
  i18n (~> 1.0)
45
- jekyll-sass-converter (~> 2.0)
47
+ jekyll-sass-converter (>= 2.0, < 4.0)
46
48
  jekyll-watch (~> 2.0)
47
- kramdown (~> 2.3)
49
+ kramdown (~> 2.3, >= 2.3.1)
48
50
  kramdown-parser-gfm (~> 1.0)
49
51
  liquid (~> 4.0)
50
- mercenary (~> 0.4.0)
52
+ mercenary (>= 0.3.6, < 0.5)
51
53
  pathutil (~> 0.9)
52
- rouge (~> 3.0)
54
+ rouge (>= 3.0, < 5.0)
53
55
  safe_yaml (~> 1.0)
54
- terminal-table (~> 2.0)
55
- jekyll-sass-converter (2.1.0)
56
- sassc (> 2.0.1, < 3.0)
56
+ terminal-table (>= 1.8, < 4.0)
57
+ webrick (~> 1.7)
58
+ jekyll-sass-converter (3.0.0)
59
+ sass-embedded (~> 1.54)
57
60
  jekyll-watch (2.2.1)
58
61
  listen (~> 3.0)
59
- kramdown (2.3.1)
62
+ kramdown (2.4.0)
60
63
  rexml
61
64
  kramdown-parser-gfm (1.1.0)
62
65
  kramdown (~> 2.0)
63
- liquid (4.0.3)
64
- listen (3.5.1)
66
+ liquid (4.0.4)
67
+ listen (3.8.0)
65
68
  rb-fsevent (~> 0.10, >= 0.10.3)
66
69
  rb-inotify (~> 0.9, >= 0.9.10)
67
- lumberjack (1.2.8)
70
+ lumberjack (1.2.10)
68
71
  mercenary (0.4.0)
69
72
  method_source (1.0.0)
70
73
  nenv (0.3.0)
@@ -73,40 +76,41 @@ GEM
73
76
  shellany (~> 0.0)
74
77
  pathutil (0.16.2)
75
78
  forwardable-extended (~> 2.6)
76
- pry (0.14.1)
79
+ pry (0.14.2)
77
80
  coderay (~> 1.1)
78
81
  method_source (~> 1.0)
79
- public_suffix (4.0.6)
82
+ public_suffix (5.0.4)
80
83
  rake (12.3.3)
81
- rb-fsevent (0.11.0)
84
+ rb-fsevent (0.11.2)
82
85
  rb-inotify (0.10.1)
83
86
  ffi (~> 1.0)
84
- rexml (3.2.5)
85
- rouge (3.26.0)
86
- rspec (3.10.0)
87
- rspec-core (~> 3.10.0)
88
- rspec-expectations (~> 3.10.0)
89
- rspec-mocks (~> 3.10.0)
90
- rspec-core (3.10.1)
91
- rspec-support (~> 3.10.0)
92
- rspec-expectations (3.10.1)
87
+ rexml (3.2.6)
88
+ rouge (4.2.0)
89
+ rspec (3.12.0)
90
+ rspec-core (~> 3.12.0)
91
+ rspec-expectations (~> 3.12.0)
92
+ rspec-mocks (~> 3.12.0)
93
+ rspec-core (3.12.2)
94
+ rspec-support (~> 3.12.0)
95
+ rspec-expectations (3.12.3)
93
96
  diff-lcs (>= 1.2.0, < 2.0)
94
- rspec-support (~> 3.10.0)
95
- rspec-mocks (3.10.2)
97
+ rspec-support (~> 3.12.0)
98
+ rspec-mocks (3.12.6)
96
99
  diff-lcs (>= 1.2.0, < 2.0)
97
- rspec-support (~> 3.10.0)
98
- rspec-support (3.10.2)
100
+ rspec-support (~> 3.12.0)
101
+ rspec-support (3.12.1)
99
102
  safe_yaml (1.0.5)
100
- sassc (2.4.0)
101
- ffi (~> 1.9)
103
+ sass-embedded (1.69.5-arm64-darwin)
104
+ google-protobuf (~> 3.23)
102
105
  shellany (0.0.1)
103
- terminal-table (2.0.0)
104
- unicode-display_width (~> 1.1, >= 1.1.1)
105
- thor (1.1.0)
106
- unicode-display_width (1.7.0)
106
+ terminal-table (3.0.2)
107
+ unicode-display_width (>= 1.1.1, < 3)
108
+ thor (1.3.0)
109
+ unicode-display_width (2.5.0)
110
+ webrick (1.8.1)
107
111
 
108
112
  PLATFORMS
109
- ruby
113
+ arm64-darwin-22
110
114
 
111
115
  DEPENDENCIES
112
116
  bundler
@@ -118,4 +122,4 @@ DEPENDENCIES
118
122
  rspec (~> 3.0)
119
123
 
120
124
  BUNDLED WITH
121
- 2.2.3
125
+ 2.3.26
data/README.md CHANGED
@@ -57,6 +57,35 @@ And you're away! Just run the `jekyll serve` or `jekyll build` commands with wha
57
57
 
58
58
  There is a `_data/tailwind.yml` file in the fixure site that's picked up by adding a frontmatter declaration in `tailwind.config.js`. This Tailwind config is in turn picked up by the outputted webpack config and parsed when webpack runs.
59
59
 
60
+ ### Debouncing Webpack runs
61
+ Sometimes the webpack build can take a long time. You can configure jekyll-webpack to debounce the build in a number of ways. The options are:-
62
+
63
+ - run once (when you first run `serve`)
64
+ - run every n iterations (specify a number of iterations to skip webpack compilation)
65
+ - run on watch folder changes (specific a folder to watch and only run webpack when a file in the folder has changed)
66
+
67
+ Add the following entries into `_config.yml`
68
+
69
+ ``` yml
70
+ // _config.yml
71
+
72
+ webpack:
73
+ debounce:
74
+ run_once: true
75
+
76
+ // or ...
77
+ webpack:
78
+ debounce:
79
+ every: 10
80
+
81
+ // or ...
82
+ webpack:
83
+ debounce:
84
+ watch: src
85
+ ```
86
+
87
+ This is very useful if you plan to use `jekyll serve` with the `--livereload` option as it can speed up your development time significantly.
88
+
60
89
  ### Cleanup
61
90
  If you wish to clean out unused source files after webpack has run that got included in the compiled site, you need to add an entry into your `_config.yml` like:
62
91
 
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_dependency "jekyll"
31
+ spec.add_dependency "listen"
31
32
 
32
33
  spec.add_development_dependency "bundler"
33
34
  spec.add_development_dependency "pry"
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tmpdir'
4
+ require 'listen'
5
+
6
+ module Jekyll
7
+ module Webpack
8
+ class Debouncer
9
+ attr_reader :site, :dist_path, :config, :run_once, :has_run, :run_every_n, :watch_nodes, :listener
10
+
11
+ def initialize(site, debounce_config)
12
+ @config = debounce_config
13
+ @run_once = debounce_config.dig('run_once')
14
+ @run_every_n = debounce_config.dig('every')
15
+ @watch_nodes = debounce_config.dig('watch')
16
+
17
+ if @watch_nodes
18
+ if Array === @watch_nodes
19
+ watch_paths = @watch_nodes.map { |file| File.join(site.source, file) }
20
+ else
21
+ watch_paths = [@watch_nodes]
22
+ end
23
+
24
+ @listener = Listen.to(*watch_paths) do |modified, added, removed|
25
+ @has_run = false
26
+ end
27
+ @listener.start
28
+ end
29
+
30
+ @run_counter = 0
31
+ @has_run = false
32
+ @site = site
33
+ @dist_tmpdir = Dir.mktmpdir("jekyll_webpack_dist_#{File.split(site.dest).last}")
34
+ @dist_path = File.expand_path('dist', site.dest)
35
+ end
36
+
37
+ def build
38
+ if run_once || watch_nodes
39
+ if has_run
40
+ restore_dist
41
+ else
42
+ yield
43
+ extract_dist
44
+ end
45
+ elsif run_every_n
46
+ if !has_run
47
+ yield
48
+ @run_counter += 1
49
+ extract_dist
50
+ elsif run_every_n == @run_counter
51
+ yield
52
+ @run_counter = 0
53
+ extract_dist
54
+ else
55
+ restore_dist
56
+ @run_counter += 1
57
+ end
58
+ end
59
+
60
+ @has_run = true
61
+ end
62
+
63
+ def extract_dist
64
+ FileUtils.cp_r(dist_path, @dist_tmpdir)
65
+ end
66
+
67
+ def restore_dist
68
+ FileUtils.cp_r(File.join(@dist_tmpdir, 'dist'), File.join(site.dest, 'dist'))
69
+ end
70
+ end
71
+ end
72
+ end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Webpack
3
- VERSION = "0.2.5"
3
+ VERSION = "0.2.7"
4
4
  end
5
5
  end
@@ -3,21 +3,40 @@
3
3
  require "jekyll/webpack/version"
4
4
  require "jekyll"
5
5
  require "open3"
6
+ require 'tmpdir'
7
+ require 'jekyll/webpack/debouncer'
6
8
 
7
9
  module Jekyll
8
10
  module Webpack
11
+
12
+ @@webpack_debouncers = {}
13
+
9
14
  class Error < StandardError; end
10
15
 
11
16
  def self.build(site)
17
+ only_in = site.config.dig('webpack', 'only_in')
18
+ debounce = site.config.dig('webpack', 'debounce')
19
+
12
20
  site_dest = site.dest
21
+ webpack_dist_path = File.expand_path('dist', site.dest)
13
22
 
14
- only_in = site.config.dig('webpack', 'only_in')
15
23
  if only_in
16
24
  entries = []
17
25
  array_or_scalar(only_in) { |entry| entries << site_dest.end_with?(entry) }
18
26
  return unless entries.any? true
19
27
  end
20
28
 
29
+ if debounce
30
+ @@webpack_debouncers[site.dest] = Debouncer.new(site, debounce) unless @@webpack_debouncers[site.dest]
31
+ @@webpack_debouncers[site.dest].build { webpack_exec(site_dest) }
32
+ else
33
+ webpack_exec(site_dest)
34
+ end
35
+
36
+ cleanup(site)
37
+ end
38
+
39
+ def self.webpack_exec(site_dest)
21
40
  stdout, stderr, status = Open3.capture3(
22
41
  "../node_modules/.bin/webpack",
23
42
  chdir: File.expand_path(site_dest)
@@ -27,8 +46,6 @@ module Jekyll
27
46
 
28
47
  raise Error, stderr if stderr.size > 0
29
48
  raise Error, stdout if !runtime_error.nil?
30
-
31
- cleanup(site)
32
49
  end
33
50
 
34
51
  def self.cleanup(site)
@@ -38,7 +55,7 @@ module Jekyll
38
55
  array_or_scalar(cleanup_files) do |dest_for_clean|
39
56
  path = File.expand_path(dest_for_clean, site.dest)
40
57
 
41
- if File.exists?(path) || Dir.exists?(path)
58
+ if File.exist?(path) || Dir.exist?(path)
42
59
  FileUtils.rm_rf(path)
43
60
  end
44
61
  end
@@ -59,6 +76,11 @@ module Jekyll
59
76
  end
60
77
  end
61
78
 
79
+
80
+ # Jekyll::Hooks.register :site, :after_init do |site|
81
+ # Jekyll::Webpack.extract_dist(site)
82
+ # end
83
+
62
84
  Jekyll::Hooks.register :site, :post_write do |site|
63
- Jekyll::Webpack.build(site)
85
+ Jekyll::Webpack.build(site)
64
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-webpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Martin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-27 00:00:00.000000000 Z
11
+ date: 2023-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: listen
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -130,6 +144,7 @@ files:
130
144
  - bin/setup
131
145
  - jekyll-webpack.gemspec
132
146
  - lib/jekyll/webpack.rb
147
+ - lib/jekyll/webpack/debouncer.rb
133
148
  - lib/jekyll/webpack/version.rb
134
149
  homepage: https://github.com/tevio/jekyll-webpack
135
150
  licenses:
@@ -152,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
167
  - !ruby/object:Gem::Version
153
168
  version: '0'
154
169
  requirements: []
155
- rubygems_version: 3.2.3
170
+ rubygems_version: 3.3.26
156
171
  signing_key:
157
172
  specification_version: 4
158
173
  summary: Compile assets with webpack