diff --git a/projects/js-packages/publicize-components/changelog/fix-social-admin-page-assets-public-path b/projects/js-packages/publicize-components/changelog/fix-social-admin-page-assets-public-path new file mode 100644 index 0000000000000..08857fc500853 --- /dev/null +++ b/projects/js-packages/publicize-components/changelog/fix-social-admin-page-assets-public-path @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixed webpack publicPath issue for Social admin. diff --git a/projects/js-packages/publicize-components/src/components/admin-page/entry-point.tsx b/projects/js-packages/publicize-components/src/components/admin-page/entry-point.tsx index 0800bf6d47a76..4c49d074b26fc 100644 --- a/projects/js-packages/publicize-components/src/components/admin-page/entry-point.tsx +++ b/projects/js-packages/publicize-components/src/components/admin-page/entry-point.tsx @@ -1,3 +1,4 @@ +import '../../set-webpack-public-path'; import { ThemeProvider } from '@automattic/jetpack-components'; import * as WPElement from '@wordpress/element'; import React from 'react'; diff --git a/projects/js-packages/publicize-components/src/set-webpack-public-path.js b/projects/js-packages/publicize-components/src/set-webpack-public-path.js new file mode 100644 index 0000000000000..d4c81ac0c0a9b --- /dev/null +++ b/projects/js-packages/publicize-components/src/set-webpack-public-path.js @@ -0,0 +1,12 @@ +/* exported __webpack_public_path__ */ +/* global __webpack_public_path__ */ + +/** + * Dynamically set WebPack's publicPath so that split assets can be found. + * This ensures that assets (like images) are loaded from the correct path + * regardless of the environment (WordPress.com, Simple sites, etc.). + */ +if ( typeof window === 'object' && window.JetpackScriptData?.social?.urls?.webpackPublicPath ) { + // eslint-disable-next-line no-global-assign + __webpack_public_path__ = window.JetpackScriptData.social.urls.webpackPublicPath; +} diff --git a/projects/packages/publicize/changelog/fix-social-admin-page-assets-public-path b/projects/packages/publicize/changelog/fix-social-admin-page-assets-public-path new file mode 100644 index 0000000000000..08857fc500853 --- /dev/null +++ b/projects/packages/publicize/changelog/fix-social-admin-page-assets-public-path @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixed webpack publicPath issue for Social admin. diff --git a/projects/packages/publicize/src/class-publicize-script-data.php b/projects/packages/publicize/src/class-publicize-script-data.php index 3747f118c8340..b2779bbae54b6 100644 --- a/projects/packages/publicize/src/class-publicize-script-data.php +++ b/projects/packages/publicize/src/class-publicize-script-data.php @@ -310,6 +310,7 @@ public static function get_urls() { $urls = array( 'connectionsManagementPage' => self::publicize()->publicize_connections_url(), + 'webpackPublicPath' => plugins_url( '/build/', __DIR__ ), ); // Escape the URLs. diff --git a/projects/plugins/jetpack/changelog/fix-social-admin-page-assets-public-path b/projects/plugins/jetpack/changelog/fix-social-admin-page-assets-public-path new file mode 100644 index 0000000000000..7d51654129ad7 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-social-admin-page-assets-public-path @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Fixed webpack publicPath issue for Social admin. diff --git a/projects/plugins/social/changelog/fix-social-admin-page-assets-public-path b/projects/plugins/social/changelog/fix-social-admin-page-assets-public-path new file mode 100644 index 0000000000000..08857fc500853 --- /dev/null +++ b/projects/plugins/social/changelog/fix-social-admin-page-assets-public-path @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixed webpack publicPath issue for Social admin.