nanoc-webpack.rb 0.4.5 → 0.5.1

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: df4465f1a027bcab47a46e8566759337c6e7011ffe3d3027e80152acda750568
4
+ data.tar.gz: a3315918c27fd3adfa6fc91f7dc62e747b15172454e60d2018d0ca23f932adc1
5
5
  SHA512:
6
- metadata.gz: 1cbd5df5b9e003e2cd5bb96213aa0852fa306f2ec91dab060d61a3930253a62591919fb15917a811c06afe6b322a3a7316dcf1b8a7e8c82827dcf361f8774b39
7
- data.tar.gz: 2a5a8f3854cb9164b8b20d02e9920f20cb5143f57457a67db387f8225ce1382d6f100547c1e42e486f070985f302437e8a6d3fcdb4231cefd200d37a83a5cf43
6
+ metadata.gz: cbe5c24b15ee54980d48629ed95ffb0616566f1d5ab56bfc37f2607dc209dffcd1dccc2b038e51fec4c7d819391869e74b4a765671d93cda2bcd4b89917e6552
7
+ data.tar.gz: 3b2c884d85875026ac1438013d9f0618c5a9d6c735386cd97c6df2c7102c1c872eb418cfbe7728fd5fcddc2d81d3f4d934a0271937cedb9ba4467b11d89a646f
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.1"
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/).
@@ -11,20 +11,30 @@ class Nanoc::Webpack::Filter < Nanoc::Filter
11
11
  identifier :webpack
12
12
  type :text
13
13
 
14
+ ##
15
+ # @return [Hash]
16
+ # Returns the default command-line options given
17
+ # to the webpack executable.
18
+ def self.default_options
19
+ @default_options ||= {}
20
+ end
21
+
14
22
  def run(content, options = {})
15
23
  depend_on dependable(paths: options[:depend_on], reject: options[:reject])
16
24
  .map { items[_1] }
17
- webpack(temp_file(content))
25
+ webpack temporary_file_for(content),
26
+ args: self.class.default_options.merge(options[:args])
18
27
  end
19
28
 
20
29
  private
21
30
 
22
- def webpack(file)
31
+ def webpack(file, args: [])
23
32
  system "node",
24
33
  "./node_modules/webpack/bin/webpack.js",
25
34
  "--entry", File.join(Dir.getwd, item.attributes[:content_filename]),
26
35
  "--output-path", File.dirname(file.path),
27
- "--output-filename", File.basename(file.path)
36
+ "--output-filename", File.basename(file.path),
37
+ *webpack_args(cli)
28
38
  if $?.success?
29
39
  File.read(file.path).tap { file.tap(&:unlink).close }
30
40
  else
@@ -34,8 +44,18 @@ class Nanoc::Webpack::Filter < Nanoc::Filter
34
44
  end
35
45
  end
36
46
 
37
- def temp_file(content)
38
- dir = File.join(Dir.getwd, "tmp", "webpack")
47
+ def webpack_args(args)
48
+ args.each_with_object([]) do |(key, value), ary|
49
+ if value.equal?(true)
50
+ ary << key
51
+ else
52
+ ary.concat [key, value.to_s]
53
+ end
54
+ end
55
+ end
56
+
57
+ def temporary_file_for(content)
58
+ dir = File.join(Dir.getwd, "tmp", "nanoc-webpack.rb")
39
59
  mkdir_p(dir) unless Dir.exist?(dir)
40
60
  file = Tempfile.new(File.basename(item.identifier.to_s), dir)
41
61
  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.1"
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.1
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: []