Perry J
Perry J

Reputation: 365

Yii2: use fxp assets plugin or asset-packagist?

Seems like yii2 has some unresolved conflict between using the asset-packagist.org method, or the older fxp assets plugin. I am now working with a project, intended to use the asset-packagist. All settings appear OK, but Yii2 seems to ignore it all and insist on using a bower directory that does not exist. Using the asset-packagist method, this directory is called bower-asset.

The settings: To make this work, we use (in common/config/base.php):

'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
 ],

...and in composer.json we set:

 "repositories": [
{
    "type": "composer",
    "url": "https://asset-packagist.org"
}
],

That does not help, however, still getting the error:

 The file or directory to be published does not exist: 
 C:\....common\config/../../vendor/bower/semantic/dist

Also tried to switch fxp off with (in composer.json):

 "config": {
"fxp-asset": {
        "enabled": false
    }
  },

Also tried command:

 composer global remove fxp/composer-asset-plugin  --no-plugins

Same thing.

Note: The project was developed in Linux, I am now trying open it in Windows 10 and XAMPP on localhost. Feel free to tell me if Windows-related.

Upvotes: 2

Views: 2324

Answers (1)

Perry J
Perry J

Reputation: 365

To get this to work, I had to choose the fxp-plugin, and to let go of the asset-packagist way (it simply does not work, given the knowledge I have at this point), like this:

  • Removed the reference to asset-packagist.org from repositories section in composer.json (in my case I removed the whole repositories section.:
   "repositories": [
    {
    "type": "composer",
    "url": "https://asset-packagist.org"
    }
    ],
  • Install the latest composer fxp-plugin, currently 1.4.6:

composer global require "fxp/composer-asset-plugin:~1.4.6"

  • Removed the @bower -> bower-asset (and those for npm) aliases in common/config/base.php.
  • Then, now it finds the correct path if you rename the bower-asset folder in vendor to "bower". But you should never change anything in the vendor folder, instead, add this fxp-asset section to "config" in composer.json:
 "config": {
            "process-timeout": 1800,
            "fxp-asset":{
                "installer-paths": {
                    "npm-asset-library": "vendor/npm",
                    "bower-asset-library": "vendor/bower"
            }
        }
    }
  • Then remove the vendor folder, remove the Composer.lock file and run composer install .

Upvotes: 2

Related Questions