I’m maintaining some dependencies and its versions using npm.
E.g. Bootstrap and FontAwesome. I cannot use a CDN for these as I’m changing some sass variables.
Now in my main scss file I can include sass files from node_modules
folder like:
@import "../node_modules/bootstrap/scss/bootstrap";
@import "../node_modules/@fortawesome/fontawesome-pro/scss/fontawesome";
But e.g. FontAwesome also needs the webfonts folder relative to the css folder.
So I’m trying to “mount” node_modules/@fortawesome/fontawesome-pro/webfonts
to assets/webfonts
.
I’m calling it “mounts” as GoHugo has something like that: https://gohugo.io/commands/hugo_config_mounts/
With GoHugo I would configure it like:
module:
mounts:
- source: node_modules/@fortawesome/fontawesome-pro/webfonts
target: assets/webfonts
Now I don’t think Jekyll has something like that, but I wonder if there is another option to do this?
Of course I don’t want to expose the node_modules
folder itself.
I also tried with a custom CopyAssets
generator like:
require "fileutils"
module Jekyll
class CopyAssets < Jekyll::Generator
safe true
priority :lowest
def generate(site)
assets = {
"node_modules/@fortawesome/fontawesome-pro/webfonts": "webfonts"
}
assets.each { |src, dest|
src = "#{site.source}/#{src}"
dest = "#{site.dest}/assets/#{dest}"
FileUtils.mkdir_p dest, :verbose => true
FileUtils.cp_r src, dest, :verbose => true
}
end
end
end
but that doesn’t work, the folders are copies but then in the Jekyll build process deleted again.