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 +4 -4
- data/.bundle/config +2 -0
- data/.gitignore +1 -0
- data/Gemfile +0 -1
- data/README.md +29 -0
- data/lib/nanoc/webpack/filter.rb +25 -5
- data/lib/nanoc/webpack/version.rb +1 -1
- data/nanoc-webpack.rb.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df4465f1a027bcab47a46e8566759337c6e7011ffe3d3027e80152acda750568
|
4
|
+
data.tar.gz: a3315918c27fd3adfa6fc91f7dc62e747b15172454e60d2018d0ca23f932adc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbe5c24b15ee54980d48629ed95ffb0616566f1d5ab56bfc37f2607dc209dffcd1dccc2b038e51fec4c7d819391869e74b4a765671d93cda2bcd4b89917e6552
|
7
|
+
data.tar.gz: 3b2c884d85875026ac1438013d9f0618c5a9d6c735386cd97c6df2c7102c1c872eb418cfbe7728fd5fcddc2d81d3f4d934a0271937cedb9ba4467b11d89a646f
|
data/.bundle/config
ADDED
data/.gitignore
CHANGED
data/Gemfile
CHANGED
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/).
|
data/lib/nanoc/webpack/filter.rb
CHANGED
@@ -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(
|
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
|
38
|
-
|
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)
|
data/nanoc-webpack.rb.gemspec
CHANGED
@@ -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 = "
|
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
|
+
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:
|
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:
|
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.
|
140
|
+
rubygems_version: 3.5.3
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
|
-
summary:
|
143
|
+
summary: nanoc-webpack.rb integrates webpack into nanoc.
|
143
144
|
test_files: []
|