Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: minifier doesn't work without assets/vendor #23

Open
snayam opened this issue Nov 23, 2024 · 9 comments
Open

Bug: minifier doesn't work without assets/vendor #23

snayam opened this issue Nov 23, 2024 · 9 comments

Comments

@snayam
Copy link

snayam commented Nov 23, 2024

No description provided.

@snayam
Copy link
Author

snayam commented Nov 23, 2024

I use asset-mapper but without third-party packages, so i removed the assets/vendor folder. In this case, files are not minified after asset-map:compile.

To work, i have to 2 solutions :

  1. Create empty asset/vendor folder, or
  2. Set ignore_vendor to false in sensiolabs_minify config

@snayam snayam changed the title Bug: minifier doesnot work Bug: minifier doesn't work without asset/vendor Nov 23, 2024
@snayam snayam changed the title Bug: minifier doesn't work without asset/vendor Bug: minifier doesn't work without assets/vendor Nov 23, 2024
@smnandre
Copy link
Collaborator

hi @snayam !
I just pushed a fix and deployed a new version, could you check and tell me if it solves your problem?

@snayam
Copy link
Author

snayam commented Nov 24, 2024

Hi @smnandre

I've just tried but same problem :-(

assets/vendor folder present => asset-map:compile -> minifier works fine !
assets/vendor folder not present => asset-map:compile -> minifier doesn't work

In logs, i have the following php debug message, but display in the 2 cases so i don't think it's related :

php.DEBUG: Warning: mkdir(): File exists {"exception":{"Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext":{"severity":2,"file":"/vendor/symfony/asset-mapper/CompiledAssetMapperConfigReader.php","line":43,"trace":[{"file":"/vendor/symfony/asset-mapper/Command/AssetMapperCompileCommand.php","line":78,"function":"saveConfig","class":"Symfony\\Component\\AssetMapper\\CompiledAssetMapperConfigReader","type":"->"}],"count":1}}} []

Symfony 7.1.8 / PHP 8.2.25

@smnandre
Copy link
Collaborator

Could you, just to be sure, run this command ?

php bin/console c:c && php bin/console debug:container --tag asset_mapper

assets/vendor folder present => asset-map:compile -> minifier works fine !
assets/vendor folder not present => asset-map:compile -> minifier doesn't work

Same thing, just to be sure, you do clear (bin/console c:p:c --all) and reset assets (rm -rf public/assets) between these tests ?

@snayam
Copy link
Author

snayam commented Nov 25, 2024

Could you, just to be sure, run this command ?

php bin/console c:c && php bin/console debug:container --tag asset_mapper
Capture d’écran 2024-11-25 à 09 22 12

Same thing, just to be sure, you do clear (bin/console c:p:c --all) and reset assets (rm -rf public/assets) between these tests ?

Done but same problem.

I think the issue comes from supports function (MinifierCompiler.php).
Here, $asset->isVendor return true when assets/vendor is present ; false when is not present.

public function supports(MappedAsset $asset): bool
    {
        if (!in_array($asset->publicExtension, $this->extensions, true)) {
            return false;
        }

        if ($this->ignoreVendor && $asset->isVendor) {
            return false;
        }

        foreach ($this->ignorePaths as $ignorePath) {
            if (fnmatch($ignorePath, $asset->sourcePath)) {
                return false;
            }
        }

        return true;
    }

@smnandre
Copy link
Collaborator

Here, $asset->isVendor return true when assets/vendor is present ; false when is not present.

For wich asset ? One in particular or all of them ?

@smnandre
Copy link
Collaborator

I think this is due to this bug (fixed and released in the next version) .. not something related to this bundle :/

symfony/symfony@9e3984f

@snayam
Copy link
Author

snayam commented Nov 26, 2024

Here, $asset->isVendor return true when assets/vendor is present ; false when is not present.

For wich asset ? One in particular or all of them ?

All of them.

I think this is due to this bug (fixed and released in the next version) .. not something related to this bundle :/

symfony/symfony@9e3984f

Yes, it seems that the problem comes more from AssetMapper.

@smnandre
Copy link
Collaborator

Did you check if Symfony 7.2 solves your issue @snayam ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants