Closed ashmaroli closed 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?
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..
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
Hi, :wave: Running
bundle exec jekyll serve
after adding the gem and config block to a test site errors out with the following messageCopying 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.