Class: Nanoc::Webpack::Filter
- Inherits:
-
Filter
- Object
- Filter
- Nanoc::Webpack::Filter
- Includes:
- FileUtils, Dependable, Spawn
- Defined in:
- lib/nanoc/webpack/filter/dependable.rb,
lib/nanoc/webpack/filter.rb
Defined Under Namespace
Modules: Dependable
Constant Summary
Constants included from Spawn
Class Method Summary collapse
-
.default_argv ⇒ Array<String>
The default argv for webpack.
Instance Method Summary collapse
Methods included from Spawn
Methods included from Dependable
Class Method Details
.default_argv ⇒ Array<String>
The default argv for webpack
24 25 26 |
# File 'lib/nanoc/webpack/filter.rb', line 24 def self.default_argv @default_argv ||= [] end |
Instance Method Details
#run(content, options = {}) ⇒ void
This method returns an undefined value.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/nanoc/webpack/filter.rb', line 36 def run(content, = {}) = Ryo.from() file = temporary_file(content) depend_on dependable(paths: .depend_on, reject: .reject) .map { items[_1] } argv = [*(.argv || []), *default_argv] scan(argv) spawn "node", ["./node_modules/webpack/bin/webpack.js", *argv, "--entry", File.join(Dir.getwd, item.attributes[:content_filename]), "--output-path", File.dirname(file.path), "--output-filename", File.basename(file.path)] File.read(file.path) ensure file ? file.tap(&:unlink).close : nil end |