Skip to content

Bundle Javascript & Stylesheets from package.json (Yarn) with PHP.

License

Notifications You must be signed in to change notification settings

drhino/phpackage-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phpackage-json

Bundle Javascript & Stylesheets from package.json (Yarn) with PHP.

$ composer require wbadrh/phpackage-json

Example: https://github.com/wbadrh/phpackage-json-example

require __DIR__ . '/../vendor/autoload.php';

$assets = new PHPackage(
    __DIR__ . '/../package.json',  // yarn package
    __DIR__ . '/../node_modules/', // yarn vendor
    [
        // custom css
        __DIR__ . '/src/css/*'     // user stylesheets
    ],
    [
        // custom js
        __DIR__ . '/src/js/*'      // user javascript
    ],
    [
        // exclude
        'index.js',
    ]
);

$assets->fonts(__DIR__ . '/fonts');
<link href="<?= $assets->css(__DIR__, '/css/bundle.min.css') ?>" rel="stylesheet">
<script src="<?= $assets->js(__DIR__, '/js/bundle.min.js') ?>"></script>