Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
Webpacker::Manifest#lookup
public API (#1853)
I'm using [Service Workers](https://developers.google.com/web/fundamentals/primers/service-workers/?hl=en) with this gem. To register a Service Worker in a browser, the path of `sw.js` file is needed. ```js navigator.serviceWorker.register('/path-to-sw.js')` ``` But `Webpacker::Manifest#lookup` and `Webpacker::Manifest#lookup!` seem to be nodoc. Could you make them public API? My usage of these methods is following: ```erb <!DOCTYPE html> <html> <head> <script> window.serviceWorkerPath = "<%= Webpacker.manifest.lookup!('sw.js') %>"; </script> <link href="/manifest.json" rel="manifest"> ``` ```js // app/javascript/packs/application.js document.addEventListener("DOMContentLoaded", () => { if ('serviceWorker' in navigator) { navigator.serviceWorker.register(window.serviceWorkerPath); } }); ```
- Loading branch information