yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.9k forks source link

Asset Manager ignoring publish options with symlinks enabled #14005

Open geo-developer opened 7 years ago

geo-developer commented 7 years ago

Hello guys,

So when i was configuring my asset manager with symlinks i got into this issue that when the option for symlinks is enabled in yii the publish options are partially or fully ignored by the asset manager. The option is linkAssets :

'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' => [
                    'js' => [
                        YII_ENV_DEV ? 'jquery.js' : 'jquery.min.js' // Dev mode normal js file, production with minified file
                    ],
                ],
                'yii\bootstrap\BootstrapPluginAsset' => [
                    'js' => [
                        YII_ENV_DEV ? 'js/bootstrap.js' : 'js/bootstrap.min.js', // Dev mode normal js file, production with minified file
                    ],
                ],
            ],
            'linkAssets' => true,
            'appendTimestamp' => true

And with this simple Asset:

class MaterialDesignLiteAsset extends AssetBundle
{
    public $sourcePath = "@bower/material-design-lite";

    public $css = [
        YII_ENV_DEV ? 'material.css' : 'material.min.css'
    ];
    public $js = [
        YII_ENV_DEV ? 'material.js' : 'material.min.js'
    ];

    public $publishOptions = [
        'only' => [
            'material.*',
        ],
        'except' => [
            "src/*",
            "utils/*",
            "*.scss",
            "*.map"
        ]
    ];
}

If i have the linkAssets to true in my config/web file the output i get is this one:

yii2-bug2

And with linkAssets to false we get this:

yii2-bug

In both examples the expanded folders are the generated by asset manager, so you can see that we linkAssets is set to true the asset manager creates a symbolic link to every file in sourcePath ignoring the publishOptions that i have set in that AssetBundle, which doesn't happen when i put linkAssets to false and only the desired files are copied.

Thanks for the help, Pedro Rosa

Additional info

Q A
Yii version 2.0.11.2
PHP version 7.0.15
Operating system Ubuntu 16.04
lenyy commented 6 years ago

Hey guys. nothing new on the issue?

samdark commented 6 years ago

No. Have you reproduced it?

lenyy commented 6 years ago

Yeah just as described in issue. It was reported in Yii 2.0.11 but probably still resides de issue and i haven't tested with new Yii versions, but with Yii 2.0.11 i can be sure the error happens and the symlinks don't respect the publish options Btw i'm the one who posted the issue, but with a different account.

samdark commented 6 years ago

Please check with latest version. Thanks.