antiseptikk / wordpress-encore
API to enqueue assets generated by @webpack/encore into your WordPress theme.
Installs: 1 922
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=7.4 || <=8.2
Requires (Dev)
README
Simple and light script to handle and register Webpack Encore assets to WordPress.
Installation
Using Composer
composer require antiseptikk/wordpress-encore
Then in your functions.php
file of your theme, load composer auto-loader.
<?php require_once __DIR__ . '/vendor/autoload.php'; $encore = new \Antiseptikk\Encore('build', '1.0.0', 'my-website.com');
Using WPress composer-skeleton
We recommend using WPress composer-skeleton for using this library,
you can use config constants like WP_HOME
<?php $encore = new \Antiseptikk\Encore('build', '1.0.0', WP_HOME);
Example
<?php use Antiseptikk\Encore; class Bootstrap { private $encore; public function __constuct() { $this->encore = new Encore('build', '1.0.0', WP_HOME); add_action('wp_enqueue_scripts', [$this, 'enqueue_assets']); } public function enqueue_assets() { $this->encore->enqueue('app', 'main', []); } }
Contribution
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.