Hello @iamkunaldesai
Thanks for trying out our humble plugin.
As of now, there is no easy way for this, but this is something we have in our roadmap already.
I have added this ticket to our tracker and will file this as a feature request.
Thanks again.
Thanks for the kind words and all the feedback @iamkunaldesai 🙂
Best regards.
You can do it as I do, by adding filter to superpwa_sw_template
hook. Like this:
to you functions.php
/**
* Additional urls are passed from external resources to anonymous function
*/
add_filter('superpwa_sw_template', function($template) use ($additional_urls) {
global $urls_list;
$urls_list = is_array($urls_list) ? $urls_list : [];
$urls_list = array_merge($additional_urls, $urls_list);
$pattern = '/(const filesToCache = \[.*)(\];)/';
$replacement = sprintf('\\1%s\\2', count($urls_list) >= 2 ? ', \'' . implode('\',\'', $urls_list) . '\'' : ( count($urls_list) > 0 ? ', ' . $urls_list[0] : ''));
return preg_replace($pattern, $replacement, $template);
});
You can play with internal code part in here:
http://sandbox.onlinephpfunctions.com/code/a370634c6225b7062cecc263be93ede642e4bb11
-
This reply was modified 9 months, 3 weeks ago by
juslintek.
Thanks @juslintek
Glad to see someone making use of the filters that were just added already 🙂
Thanks @juslintek for the code.
Humanly Yours