wbadrh/phpackage-json

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

1.0.5 2017-10-27 04:15 UTC

This package is auto-updated.

Last update: 2024-11-25 23:34:36 UTC


README

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>