Skip to content

antiseptikk/wordpress-encore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Packagist

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');

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.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages