jekyll-webpack 0.2.0 → 0.2.4

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: d8950c117cac046785121b78e1211c96c2f4ff14f1982cc5864c007600abe74c
4
- data.tar.gz: 7d54401b026fe77b989e7c3f03930e4d356cfeef071cf61e7044fc7cd01cf5d2
3
+ metadata.gz: 33dede3fdb6014a97d8f77a9db5dd151ca0c9ba9a11c7a3fc9a5bcb3c24b150d
4
+ data.tar.gz: 6c523b04a532a1edb0565e2ec31b1e70f37c6fbf4349b3e19d13c22c77e873ee
5
5
  SHA512:
6
- metadata.gz: 663677f25c77ec5bdd8695eee148ebe5257fbc5f23bffd90bb3a4f9bd26e42c25d55adef1aab2a9c22711440ad786dc2b9624b676b5645d08a78237520cfd842
7
- data.tar.gz: fa519caed15b050b873cae81b437d000d75423cbf980c9a10db8215cc5cd684e68dd09965dec92e5f9cd7f05d808b880c4365f35c01b4c41dc063d8edc7f908f
6
+ metadata.gz: d291a385e04da5a17b60b783e8c4e617d38cbcb36a9b4985600cc32cb54fface89764e06623e0b5d2a66c6fec6df7a7719d8f499e3817fc0b937f8efbcad667f
7
+ data.tar.gz: 0f587a0f0b3ca7439b978a20f57f395620435739f7b594374416d5c6abe926a03837a6efdb8fe1b541cbf9363e150184ba748a86ca7479ece1e2fcd9cac83d04
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /tmp/
9
9
  /spec/fixtures/.jekyll-cache/
10
10
  /spec/fixtures/_site/
11
+ /spec/fixtures/dist/
11
12
  /spec/fixtures/node_modules/
12
13
  /*.gem
13
14
 
data/Gemfile.lock CHANGED
@@ -1,32 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-webpack (0.1.2)
4
+ jekyll-webpack (0.2.3)
5
5
  jekyll
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.7.0)
10
+ addressable (2.8.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
12
  coderay (1.1.3)
13
13
  colorator (1.1.0)
14
- concurrent-ruby (1.1.6)
15
- diff-lcs (1.3)
16
- em-websocket (0.5.1)
14
+ concurrent-ruby (1.1.9)
15
+ diff-lcs (1.4.4)
16
+ em-websocket (0.5.2)
17
17
  eventmachine (>= 0.12.9)
18
18
  http_parser.rb (~> 0.6.0)
19
19
  eventmachine (1.2.7)
20
- ffi (1.13.0)
21
- formatador (0.2.5)
20
+ ffi (1.15.3)
21
+ formatador (0.3.0)
22
22
  forwardable-extended (2.6.0)
23
- guard (2.16.2)
23
+ guard (2.18.0)
24
24
  formatador (>= 0.2.4)
25
25
  listen (>= 2.7, < 4.0)
26
26
  lumberjack (>= 1.0.12, < 2.0)
27
27
  nenv (~> 0.1)
28
28
  notiffany (~> 0.0)
29
- pry (>= 0.9.12)
29
+ pry (>= 0.13.0)
30
30
  shellany (~> 0.0)
31
31
  thor (>= 0.18.1)
32
32
  guard-compat (1.2.1)
@@ -35,36 +35,36 @@ GEM
35
35
  guard-compat (~> 1.1)
36
36
  rspec (>= 2.99.0, < 4.0)
37
37
  http_parser.rb (0.6.0)
38
- i18n (1.8.3)
38
+ i18n (1.8.10)
39
39
  concurrent-ruby (~> 1.0)
40
- jekyll (4.1.0)
40
+ jekyll (4.2.0)
41
41
  addressable (~> 2.4)
42
42
  colorator (~> 1.0)
43
43
  em-websocket (~> 0.5)
44
44
  i18n (~> 1.0)
45
45
  jekyll-sass-converter (~> 2.0)
46
46
  jekyll-watch (~> 2.0)
47
- kramdown (~> 2.1)
47
+ kramdown (~> 2.3)
48
48
  kramdown-parser-gfm (~> 1.0)
49
49
  liquid (~> 4.0)
50
50
  mercenary (~> 0.4.0)
51
51
  pathutil (~> 0.9)
52
52
  rouge (~> 3.0)
53
53
  safe_yaml (~> 1.0)
54
- terminal-table (~> 1.8)
54
+ terminal-table (~> 2.0)
55
55
  jekyll-sass-converter (2.1.0)
56
56
  sassc (> 2.0.1, < 3.0)
57
57
  jekyll-watch (2.2.1)
58
58
  listen (~> 3.0)
59
- kramdown (2.2.1)
59
+ kramdown (2.3.1)
60
60
  rexml
61
61
  kramdown-parser-gfm (1.1.0)
62
62
  kramdown (~> 2.0)
63
63
  liquid (4.0.3)
64
- listen (3.2.1)
64
+ listen (3.5.1)
65
65
  rb-fsevent (~> 0.10, >= 0.10.3)
66
66
  rb-inotify (~> 0.9, >= 0.9.10)
67
- lumberjack (1.2.5)
67
+ lumberjack (1.2.8)
68
68
  mercenary (0.4.0)
69
69
  method_source (1.0.0)
70
70
  nenv (0.3.0)
@@ -73,36 +73,36 @@ GEM
73
73
  shellany (~> 0.0)
74
74
  pathutil (0.16.2)
75
75
  forwardable-extended (~> 2.6)
76
- pry (0.13.1)
76
+ pry (0.14.1)
77
77
  coderay (~> 1.1)
78
78
  method_source (~> 1.0)
79
- public_suffix (4.0.5)
79
+ public_suffix (4.0.6)
80
80
  rake (12.3.3)
81
- rb-fsevent (0.10.4)
81
+ rb-fsevent (0.11.0)
82
82
  rb-inotify (0.10.1)
83
83
  ffi (~> 1.0)
84
- rexml (3.2.4)
85
- rouge (3.19.0)
86
- rspec (3.9.0)
87
- rspec-core (~> 3.9.0)
88
- rspec-expectations (~> 3.9.0)
89
- rspec-mocks (~> 3.9.0)
90
- rspec-core (3.9.2)
91
- rspec-support (~> 3.9.3)
92
- rspec-expectations (3.9.2)
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)
93
93
  diff-lcs (>= 1.2.0, < 2.0)
94
- rspec-support (~> 3.9.0)
95
- rspec-mocks (3.9.1)
94
+ rspec-support (~> 3.10.0)
95
+ rspec-mocks (3.10.2)
96
96
  diff-lcs (>= 1.2.0, < 2.0)
97
- rspec-support (~> 3.9.0)
98
- rspec-support (3.9.3)
97
+ rspec-support (~> 3.10.0)
98
+ rspec-support (3.10.2)
99
99
  safe_yaml (1.0.5)
100
100
  sassc (2.4.0)
101
101
  ffi (~> 1.9)
102
102
  shellany (0.0.1)
103
- terminal-table (1.8.0)
103
+ terminal-table (2.0.0)
104
104
  unicode-display_width (~> 1.1, >= 1.1.1)
105
- thor (1.0.1)
105
+ thor (1.1.0)
106
106
  unicode-display_width (1.7.0)
107
107
 
108
108
  PLATFORMS
@@ -118,4 +118,4 @@ DEPENDENCIES
118
118
  rspec (~> 3.0)
119
119
 
120
120
  BUNDLED WITH
121
- 2.1.3
121
+ 2.2.3
data/README.md CHANGED
@@ -6,8 +6,6 @@ This plugin will allow you to build your assets with Webpack _after_ Jekyll has
6
6
 
7
7
  This adds Webpack at a sane point in the build pipeline and will also allow you to parameterize your webpack and other JS config files by prepending them with front matter, before the compilation occurs. You can see a functioning example in the `spec/fixtures` folder:-
8
8
 
9
- 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.
10
-
11
9
 
12
10
  ## Installation
13
11
 
@@ -29,7 +27,18 @@ And add the following to your site's `_config.yml`
29
27
 
30
28
  ```yml
31
29
  plugins:
32
- - jekyll-webpack
30
+ - jekyll/webpack
31
+ ```
32
+
33
+ NOTE the `/` - the `-` variant is not available yet.
34
+
35
+ ALSO NOTE - it's probably advisable to place this plugin as the very last one in the build pipe. EG:-
36
+
37
+ ```yml
38
+ plugins:
39
+ - jekyll-otherplug
40
+ ...
41
+ - jekyll/webpack
33
42
  ```
34
43
 
35
44
  ## Usage
@@ -38,6 +47,53 @@ In your root Jekyll project folder you need to have Webpack installed, so:-
38
47
 
39
48
  `yarn add webpack webpack-cli --dev`
40
49
 
50
+ And the basic JS entrypoint `mkdir src && touch src/index.js`
51
+
52
+ And you're away! Just run the `jekyll serve` or `jekyll build` commands with whatever env you need.
53
+
54
+ ## Config
55
+
56
+ ### Configuring JS config files
57
+
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
+
60
+ ### Cleanup
61
+ 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
+
63
+ ``` yml
64
+ // _config.yml
65
+
66
+ webpack:
67
+ cleanup_files: src
68
+
69
+ // or an array
70
+
71
+ webpack:
72
+ cleanup_files:
73
+ - src
74
+ - node_modules
75
+ ```
76
+
77
+ ### Dest inclusion (excluding
78
+ If want to ensure that webpack only runs in a specific site dest (eg `_site` only, and no subdirectories) you can pass a single path value or an inclusion list of paths you want webpack to run in, at config time, by modifiying the `_config.yml` like so:
79
+
80
+ ``` yml
81
+ // _config.yml
82
+
83
+ webpack:
84
+ only_in: _site
85
+
86
+ // or as a list
87
+ webpack:
88
+ only_in:
89
+ - _site
90
+ - _build
91
+ ```
92
+
93
+ ### Example `_config.yml`
94
+ You can have a look at the possible configuration options in the fixtures config file at `spec/fixtures/_config.yml` in this repo.
95
+
96
+
41
97
  ## Development
42
98
 
43
99
  After checking out the repo, run `bin/setup` to install dependencies. Then `cd spec/fixtures && yarn` to install required JS dependencies for specs. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -11,15 +11,48 @@ module Jekyll
11
11
  def self.build(site)
12
12
  site_dest = site.dest
13
13
 
14
+ only_in = site.config.dig('webpack', 'only_in')
15
+ if only_in
16
+ entries = []
17
+ array_or_scalar(only_in) { |entry| entries << site_dest.end_with?(entry) }
18
+ return unless entries.any? true
19
+ end
20
+
14
21
  stdout, stderr, status = Open3.capture3(
15
22
  "../node_modules/.bin/webpack",
16
23
  chdir: File.expand_path(site_dest)
17
24
  )
18
25
 
19
- runtime_error = stdout =~ /error/i
26
+ runtime_error = stdout =~ /ERROR in|SyntaxError/
20
27
 
21
28
  raise Error, stderr if stderr.size > 0
22
29
  raise Error, stdout if !runtime_error.nil?
30
+
31
+ cleanup(site)
32
+ end
33
+
34
+ def self.cleanup(site)
35
+ cleanup_files = site.config.dig('webpack', 'cleanup_files')
36
+
37
+ if cleanup_files
38
+ array_or_scalar(cleanup_files) do |dest_for_clean|
39
+ if Dir.exists?(File.expand_path(dest_for_clean, site.dest))
40
+ FileUtils.rm_rf(File.expand_path(dest_for_clean, site.dest))
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def self.array_or_scalar(value)
49
+ if Array === value
50
+ value.each do |entry|
51
+ yield entry
52
+ end
53
+ else
54
+ yield value
55
+ end
23
56
  end
24
57
  end
25
58
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Webpack
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  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.0
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Martin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-09 00:00:00.000000000 Z
11
+ date: 2021-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -137,7 +137,7 @@ licenses:
137
137
  metadata:
138
138
  homepage_uri: https://github.com/tevio/jekyll-webpack
139
139
  source_code_uri: https://github.com/mml/jekyll-webpack
140
- post_install_message:
140
+ post_install_message:
141
141
  rdoc_options: []
142
142
  require_paths:
143
143
  - lib
@@ -152,8 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubygems_version: 3.1.2
156
- signing_key:
155
+ rubygems_version: 3.2.3
156
+ signing_key:
157
157
  specification_version: 4
158
158
  summary: Compile assets with webpack
159
159
  test_files: []