From 7e513162c744f3d320354817c33a26541b52e8c9 Mon Sep 17 00:00:00 2001 From: Erik Golinelli Date: Fri, 13 Oct 2023 23:24:08 +0200 Subject: [PATCH] js stuff --- admin/CF7_AntiSpam_Admin_Core.php | 4 ++-- core/CF7_AntiSpam_Frontend.php | 4 ++-- {admin/src => src}/admin-scripts.js | 0 {admin/src => src}/dashboard/dashboard.js | 0 {admin/src => src}/dashboard/dashboard.scss | 0 .../src => src}/integration/integration.scss | 0 {core/src => src}/script.js | 0 {admin/src => src}/settings/settings.js | 0 {admin/src => src}/settings/settings.scss | 0 webpack.config.js | 21 ++++++------------- 10 files changed, 10 insertions(+), 19 deletions(-) rename {admin/src => src}/admin-scripts.js (100%) rename {admin/src => src}/dashboard/dashboard.js (100%) rename {admin/src => src}/dashboard/dashboard.scss (100%) rename {admin/src => src}/integration/integration.scss (100%) rename {core/src => src}/script.js (100%) rename {admin/src => src}/settings/settings.js (100%) rename {admin/src => src}/settings/settings.scss (100%) diff --git a/admin/CF7_AntiSpam_Admin_Core.php b/admin/CF7_AntiSpam_Admin_Core.php index 99c1e6b..abc726c 100644 --- a/admin/CF7_AntiSpam_Admin_Core.php +++ b/admin/CF7_AntiSpam_Admin_Core.php @@ -188,8 +188,8 @@ public function enqueue_scripts() { * class. */ - $asset = include CF7ANTISPAM_PLUGIN_DIR . '/admin/dist/admin-scripts.asset.php'; - wp_register_script( $this->plugin_name, CF7ANTISPAM_PLUGIN_URL . '/admin/dist/admin-scripts.js', $asset['dependencies'], $asset['version'], true ); + $asset = include CF7ANTISPAM_PLUGIN_DIR . '/build/admin-scripts.asset.php'; + wp_register_script( $this->plugin_name, CF7ANTISPAM_PLUGIN_URL . '/build/admin-scripts.js', $asset['dependencies'], $asset['version'], true ); wp_enqueue_script( $this->plugin_name ); wp_localize_script( diff --git a/core/CF7_AntiSpam_Frontend.php b/core/CF7_AntiSpam_Frontend.php index 63aa000..654d438 100644 --- a/core/CF7_AntiSpam_Frontend.php +++ b/core/CF7_AntiSpam_Frontend.php @@ -410,8 +410,8 @@ public function enqueue_scripts() { * class. */ - $asset = include CF7ANTISPAM_PLUGIN_DIR . '/includes/dist/script.asset.php'; - wp_register_script( $this->plugin_name, CF7ANTISPAM_PLUGIN_URL . '/includes/dist/script.js', $asset['dependencies'], $asset['version'], true ); + $asset = include CF7ANTISPAM_PLUGIN_DIR . '/build/script.asset.php'; + wp_register_script( $this->plugin_name, CF7ANTISPAM_PLUGIN_URL . '/build/script.js', $asset['dependencies'], $asset['version'], true ); wp_enqueue_script( $this->plugin_name ); wp_localize_script( diff --git a/admin/src/admin-scripts.js b/src/admin-scripts.js similarity index 100% rename from admin/src/admin-scripts.js rename to src/admin-scripts.js diff --git a/admin/src/dashboard/dashboard.js b/src/dashboard/dashboard.js similarity index 100% rename from admin/src/dashboard/dashboard.js rename to src/dashboard/dashboard.js diff --git a/admin/src/dashboard/dashboard.scss b/src/dashboard/dashboard.scss similarity index 100% rename from admin/src/dashboard/dashboard.scss rename to src/dashboard/dashboard.scss diff --git a/admin/src/integration/integration.scss b/src/integration/integration.scss similarity index 100% rename from admin/src/integration/integration.scss rename to src/integration/integration.scss diff --git a/core/src/script.js b/src/script.js similarity index 100% rename from core/src/script.js rename to src/script.js diff --git a/admin/src/settings/settings.js b/src/settings/settings.js similarity index 100% rename from admin/src/settings/settings.js rename to src/settings/settings.js diff --git a/admin/src/settings/settings.scss b/src/settings/settings.scss similarity index 100% rename from admin/src/settings/settings.scss rename to src/settings/settings.scss diff --git a/webpack.config.js b/webpack.config.js index add573e..d524a0f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,19 +1,10 @@ const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); const path = require( 'path' ); -const addModule = ( fileName, filePath ) => { - return { - ...defaultConfig, - name: fileName, - entry: path.resolve( __dirname, filePath + fileName ), - output: { - path: path.resolve( __dirname, filePath + '../dist/' ), - filename: fileName, - }, - }; +module.exports = { + ...defaultConfig, + entry: { + script: path.resolve( process.cwd(), `src/script.js` ), + 'admin-scripts': path.resolve( process.cwd(), `src/admin-scripts.js` ), + }, }; - -const mainScript = addModule( 'script.js', 'core/src/' ); -const adminScript = addModule( 'admin-scripts.js', 'admin/src/' ); - -module.exports = [ mainScript, adminScript ];