swisnl / jQuery-contextMenu

jQuery contextMenu plugin & polyfill
https://swisnl.github.io/jQuery-contextMenu/
MIT License
2.25k stars 744 forks source link

Use Rails asset pipeline URL functions to load icon font if they exist #737

Open mgreen-lz opened 3 years ago

mgreen-lz commented 3 years ago

I'm working on fixing some 404 errors in a Rails app for work that uses jQuery-contextMenu. We're using the asset pipeline for fonts, which appends digest strings to their filenames. This causes this library's stylesheets to look for fonts in the wrong place.

This PR uses the asset pipeline's Sass helper functions if they exist to ensure that the correct font URLs end up in the compiled CSS in Rails apps. If those functions don't exists, e.g. when using Gulp to build CSS, it'll use url().

A similar approached is used by Slick Carousel to make their stylesheets' font URLs Rails friendly: https://github.com/kenwheeler/slick/blob/master/slick/slick-theme.scss#L33-L40