slejnej/asset-installer

Install npm from composer script

1.0.2 2023-10-23 12:22 UTC

This package is auto-updated.

Last update: 2024-05-23 13:39:10 UTC


README

Install all your npm assets via composer

Installation

  • install via composer composer req slejnej/asset-installer
  • add asset installation script to your composer
      "scripts": {
        "post-install-cmd": [
          "slejnej\\AssetInstaller\\InstallerHandler::installAssets"
        ]
      }
    
  • add npm packages direct to your composer
      "extra": {
        "npm": {
          "leaflet": "^1.7.1"
        }
      }
    
  • run composer install

In case

If this package is included in one of your vendor dependencies, then the scripts are not run for security reasons. As a work around you can use in primary composer.json something like this: find ./vendors -maxdepth 2 -type f -name composer.json -exec bash -c "cat {} | grep ::installAssets && composer install --working-dir $(dirname {})" \; It will find all the files that contain php command installAsset and then execute composer install in containing folder. Update ./vendors folder where it should look in and adjust maxdepth and update you composer` executable.