nanoc-webpack.rb 0.4.5 → 0.5.0

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: 4b5fa317d727a05360e4e08e5d0e343862686385597adfde1780614f634006bb
4
- data.tar.gz: 5824d38fcfc4327524856c94a80c81cb1f0d9fc636f3d540d06e2f32fbffa805
3
+ metadata.gz: fb4f774661ab8864e181668d80bcbcbc79bdd4b45ec746ebc29fae83828691b2
4
+ data.tar.gz: 05adf92c987389b5b1e6fa418b2e83c5d5b1ac7e93c9ddfd12b300ad3421be24
5
5
  SHA512:
6
- metadata.gz: 1cbd5df5b9e003e2cd5bb96213aa0852fa306f2ec91dab060d61a3930253a62591919fb15917a811c06afe6b322a3a7316dcf1b8a7e8c82827dcf361f8774b39
7
- data.tar.gz: 2a5a8f3854cb9164b8b20d02e9920f20cb5143f57457a67db387f8225ce1382d6f100547c1e42e486f070985f302437e8a6d3fcdb4231cefd200d37a83a5cf43
6
+ metadata.gz: 343e55d3a8557216618eaf5c9956daa9dfc9c08c4a11d54fca4575d021e9ebcff30c11acac5e5602a676abd05e9e50a799f395b60f3b0431f925c6731d12870b
7
+ data.tar.gz: abbeaf8c6c482dbe8ccab176970b032d7fecf72d04a8e2e46e3145a1b09bd6a7b5e7a6bccaec8bb62c0e14955dc65105ee324f3307e30e351d15394bc2a2846b
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_PATH: ".gems"
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  .yardoc/
2
+ .gems/
2
3
  /spec/fakefs/
3
4
  /pkg/
4
5
  Gemfile.lock
data/Gemfile CHANGED
@@ -3,4 +3,3 @@
3
3
  source "https://rubygems.org"
4
4
  gemspec
5
5
  gem "nanoc"
6
- gem "ryo.rb", github: "0x1eef/ryo.rb", tag: "v0.3.0"
data/README.md CHANGED
@@ -56,6 +56,22 @@ compile "/js/ReactApp.jsx" do
56
56
  end
57
57
  ```
58
58
 
59
+ __Option: "args"__
60
+
61
+ The `args` option can be used to forward command-line options directly
62
+ to the webpack executable. See `$ webpack build --help` for the list of
63
+ options that are available:
64
+
65
+ ```ruby
66
+ # Rules
67
+ require "nanoc-webpack"
68
+ compile "/js/ReactApp.jsx" do
69
+ filter :webpack, args: {"--no-stats" => true}
70
+ write("/js/app.js")
71
+ end
72
+ ```
73
+
74
+
59
75
  ## Requirements
60
76
 
61
77
  nanoc-webpack.rb assumes that:
@@ -72,12 +88,25 @@ nanoc-webpack.rb assumes that:
72
88
 
73
89
  ## <a id='install'>Install</a>
74
90
 
91
+ **Git**
92
+
75
93
  nanoc-webpack.rb is distributed as a RubyGem through its git repositories. <br>
76
94
  [GitHub](https://github.com/0x1eef/nanoc-webpack.rb),
77
95
  and
78
96
  [GitLab](https://gitlab.com/0x1eef/nanoc-webpack.rb)
79
97
  are available as sources.
80
98
 
99
+ ```ruby
100
+ # Gemfile
101
+ gem "nanoc-webpack.rb", github: "0x1eef/nanoc-webpack.rb", tag: "v0.5.0"
102
+ ```
103
+
104
+ **Rubygems.org**
105
+
106
+ nanoc-webpack.rb can also be installed via rubygems.org.
107
+
108
+ gem install nanoc-webpack.rb
109
+
81
110
  ## License
82
111
 
83
112
  [BSD Zero Clause](https://choosealicense.com/licenses/0bsd/).
@@ -14,17 +14,19 @@ class Nanoc::Webpack::Filter < Nanoc::Filter
14
14
  def run(content, options = {})
15
15
  depend_on dependable(paths: options[:depend_on], reject: options[:reject])
16
16
  .map { items[_1] }
17
- webpack(temp_file(content))
17
+ webpack temporary_file_for(content),
18
+ args: options[:args]
18
19
  end
19
20
 
20
21
  private
21
22
 
22
- def webpack(file)
23
+ def webpack(file, args: [])
23
24
  system "node",
24
25
  "./node_modules/webpack/bin/webpack.js",
25
26
  "--entry", File.join(Dir.getwd, item.attributes[:content_filename]),
26
27
  "--output-path", File.dirname(file.path),
27
- "--output-filename", File.basename(file.path)
28
+ "--output-filename", File.basename(file.path),
29
+ *webpack_args(cli)
28
30
  if $?.success?
29
31
  File.read(file.path).tap { file.tap(&:unlink).close }
30
32
  else
@@ -34,8 +36,18 @@ class Nanoc::Webpack::Filter < Nanoc::Filter
34
36
  end
35
37
  end
36
38
 
37
- def temp_file(content)
38
- dir = File.join(Dir.getwd, "tmp", "webpack")
39
+ def webpack_args(args)
40
+ args.each_with_object([]) do |(key, value), ary|
41
+ if value.equal?(true)
42
+ ary << key
43
+ else
44
+ ary.concat [key, value.to_s]
45
+ end
46
+ end
47
+ end
48
+
49
+ def temporary_file_for(content)
50
+ dir = File.join(Dir.getwd, "tmp", "nanoc-webpack.rb")
39
51
  mkdir_p(dir) unless Dir.exist?(dir)
40
52
  file = Tempfile.new(File.basename(item.identifier.to_s), dir)
41
53
  file.write(content)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Webpack
5
- VERSION = "0.4.5"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.licenses = ["0BSD"]
11
11
  gem.files = `git ls-files`.split($/)
12
12
  gem.require_paths = ["lib"]
13
- gem.summary = "A nanoc filter that can compile textual items with webpack"
13
+ gem.summary = "nanoc-webpack.rb integrates webpack into nanoc."
14
14
  gem.description = gem.summary
15
15
  gem.add_runtime_dependency "ryo.rb", "~> 0.4"
16
16
  gem.add_development_dependency "yard", "~> 0.9"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-webpack.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-13 00:00:00.000000000 Z
11
+ date: 2024-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ryo.rb
@@ -94,13 +94,14 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.11'
97
- description: A nanoc filter that can compile textual items with webpack
97
+ description: nanoc-webpack.rb integrates webpack into nanoc.
98
98
  email:
99
99
  - 0x1eef@protonmail.com
100
100
  executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".bundle/config"
104
105
  - ".github/workflows/specs.yml"
105
106
  - ".gitignore"
106
107
  - ".projectile"
@@ -136,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  - !ruby/object:Gem::Version
137
138
  version: '0'
138
139
  requirements: []
139
- rubygems_version: 3.4.10
140
+ rubygems_version: 3.5.3
140
141
  signing_key:
141
142
  specification_version: 4
142
- summary: A nanoc filter that can compile textual items with webpack
143
+ summary: nanoc-webpack.rb integrates webpack into nanoc.
143
144
  test_files: []