tevio / jekyll-webpack

Once Jekyll has built your sites HTML, run webpack against the compiled _site
MIT License
5 stars 3 forks source link

doesn't play nicely with jekyll-polyglot #3

Closed heeplr closed 3 years ago

heeplr commented 3 years ago

This plugin is simply awesome but it doesn't seem to work with plugins like polyglot that change directories. I get this error:

Traceback (most recent call last):
        32: from /usr/bin/jekyll:9:in `<main>'
        31: from /usr/bin/jekyll:9:in `load'
        30: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/exe/jekyll:15:in `<top (required)>'
        29: from /usr/lib64/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
        28: from /usr/lib64/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
        27: from /usr/lib64/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
        26: from /usr/lib64/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
        25: from /usr/lib64/ruby/gems/2.5.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
        24: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
        23: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
        22: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/command.rb:91:in `each'
        21: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
        20: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/commands/build.rb:36:in `process'
        19: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/commands/build.rb:65:in `build'
        18: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/command.rb:28:in `process_site'
        17: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-polyglot-1.3.3/lib/jekyll/polyglot/patches/jekyll/site.rb:36:in `process'
        16: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-polyglot-1.3.3/lib/jekyll/polyglot/patches/jekyll/site.rb:36:in `each'
        15: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-polyglot-1.3.3/lib/jekyll/polyglot/patches/jekyll/site.rb:37:in `block in process'
        14: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-polyglot-1.3.3/lib/jekyll/polyglot/patches/jekyll/site.rb:37:in `fork'
        13: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-polyglot-1.3.3/lib/jekyll/polyglot/patches/jekyll/site.rb:38:in `block (2 levels) in process'
        12: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-polyglot-1.3.3/lib/jekyll/polyglot/patches/jekyll/site.rb:78:in `process_language'
        11: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-polyglot-1.3.3/lib/jekyll/polyglot/patches/jekyll/site.rb:94:in `process_active_language'
        10: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/site.rb:82:in `process'
         9: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/site.rb:228:in `write'
         8: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/hooks.rb:98:in `trigger'
         7: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/hooks.rb:98:in `each'
         6: from /usr/lib64/ruby/gems/2.5.0/gems/jekyll-4.1.1/lib/jekyll/hooks.rb:99:in `block in trigger'
         5: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-webpack-0.2.1/lib/jekyll/webpack.rb:28:in `block in <top (required)>'
         4: from /home/daniel/.gem/ruby/2.5.0/gems/jekyll-webpack-0.2.1/lib/jekyll/webpack.rb:14:in `build'
         3: from /usr/lib64/ruby/2.5.0/open3.rb:258:in `capture3'
         2: from /usr/lib64/ruby/2.5.0/open3.rb:95:in `popen3'
         1: from /usr/lib64/ruby/2.5.0/open3.rb:199:in `popen_run'
/usr/lib64/ruby/2.5.0/open3.rb:199:in `spawn': No such file or directory - ../node_modules/.bin/webpack (Errno::ENOENT)

It looks like polyglot runs post_write hooks multiple times with different site.dest for each run. It would be nice, if webpack would run only once and always inside the _site directory.

tevio commented 3 years ago

@heeplr thanks! glad it's been useful. i have commented on the pr you made for this issue :)

heeplr commented 3 years ago

now one can restrict webpack to a single directory using

webpack:
    only_in: _site