Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 831 Bytes

README.md

File metadata and controls

38 lines (32 loc) · 831 Bytes

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>