lavas-project / jekyll-pwa

Jekyll plugin for PWA
MIT License
107 stars 19 forks source link

Errors out during preliminary testing #1

Closed ashmaroli closed 6 years ago

ashmaroli commented 6 years ago

Hi, :wave: Running bundle exec jekyll serve after adding the gem and config block to a test site errors out with the following message

jekyll 3.6.2 | Error:  No such file or directory @ rb_sysopen - ~/js/broadcast-channel-polyfill.js

Copying the contents of vendor from the gem seems to resolve this. Edit: Having a <source>/js/something.js before-hand does not raise an error.

xiaoiver commented 6 years ago

Hi @ashmaroli , in this plugin I want to copy two files(a polyfill & workbox) under /vendor to _site/js:

Dir.glob(File.expand_path('../vendor/**/*', __FILE__)) do |filepath_to_copy|
    basename = File.basename(filepath_to_copy)
    FileUtils.copy_file(filepath_to_copy, File.join(@site.dest, 'js', basename))

So in service worker generated, I can import these scripts correctly: importScripts('#{@site.baseurl}/js/#{vendor_file}');

Maybe I make a wrong assumption that users put their scripts in /js. Since I'm not very familiar with Ruby and Jekyll indeed, plz point it out if I make some mistakes.

What about I add a configuration item vendor_dest_dir so you can pass your JS directory in?

ashmaroli commented 6 years ago

Its a small bug. If the js directory exists by the time your plugin runs the above code, the build process completes successfully, else errors out..

ashmaroli commented 6 years ago

Maybe I make a wrong assumption that users put their scripts in /js.

Yes, that's very unpredictable. They could have their scripts at the root of their site, at ./js/ or ./assets/js/ or ./assets/scipts/ or can be inside ./_assets directory if they're using the jekyll-assets plugin