Fix: Updates webpack public path based on plugin URL

This commit is contained in:
mateuswetah 2021-08-12 09:23:23 -03:00
parent 447a97ba64
commit 2358c23371
3 changed files with 6 additions and 2 deletions

View File

@ -285,6 +285,7 @@ class Admin {
'user_caps' => $user_caps,
'user_prefs' => $prefs,
'base_url' => $TAINACAN_BASE_URL,
'plugin_dir_url' => plugin_dir_url( __DIR__ ),
'admin_url' => admin_url(),
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug(),
'theme_collection_list_url' => get_post_type_archive_link( 'tainacan-collection' ),

View File

@ -1,5 +1,8 @@
import * as conditioner from 'conditioner-core/conditioner-core.esm';
// Updates Webpack public path based on plugin folder URL, using variable obtained from server side.
__webpack_public_path__ = tainacan_plugin.plugin_dir_url + 'assets/js/';
// Checks if document is loaded
const performWhenDocumentIsLoaded = callback => {
if (/comp|inter|loaded/.test(document.readyState))

View File

@ -26,7 +26,7 @@ module.exports = {
},
output: {
path: path.resolve(__dirname, './src/assets/js/'),
publicPath: './../../../wp-content/plugins/tainacan/assets/js/',
publicPath: './wp-content/plugins/tainacan/assets/js/',
filename: '[name].js'
},
module: {
@ -96,6 +96,6 @@ module.exports = {
}),
new MomentLocalesPlugin({
localesToKeep: ['en', 'en-ca', 'en-nz', 'en-gb', 'es-au', 'es-in', 'pt-br', 'pt', 'es', 'es-us', 'es-do', 'fr', 'fr-ch', 'fr-ca', 'sv'],
}),
})
]
};