-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace WP_DEBUG with more appropriate flags #173
Conversation
8686f59
to
5d226a0
Compare
$script = file_get_contents( PWA_PLUGIN_DIR . '/' . $workbox_dir . 'workbox-sw.js' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents | ||
$script = preg_replace( '://# sourceMappingURL=.+?\.map:', '', $script ); | ||
$script .= file_get_contents( PWA_PLUGIN_DIR . '/' . $workbox_dir . 'workbox-sw.js' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents | ||
$script .= preg_replace( '://# sourceMappingURL=.+?\.map:', '', $script ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably shouldn't be appended - likely an oversight :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed in 22605b4.
$enable_debug_log = defined( 'WP_SERVICE_WORKER_DEBUG_LOG' ) && WP_SERVICE_WORKER_DEBUG_LOG; | ||
if ( ! $enable_debug_log ) { | ||
$script .= "self.__WB_DISABLE_DEV_LOGS = true;\n"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
That approach sounds good to me, thanks! |
Fixes #170.
SCRIPT_DEBUG
to indicate that non-production sources of Workbox should be used.PWA_VERSION
instead ofWP_DEBUG
to determine if it is a dev version of the plugin.By default the Workbox dev logs are disabled. To enable them, define this constant in the
wp-config.php
:This only has any effect when
SCRIPT_DEBUG
is also enabled, as it causes the Workbox dev scripts to be used. When constant is present, the service worker will have the__WB_DISABLE_DEV_LOGS
variable set which causes Workbox to not output the noisy logging messages. For more on that, GoogleChrome/workbox#1619 (comment).