skeeks-semenov / yii2-assets-auto-compress

Automatic compilation of js + css + html
https://skeeks.com/
BSD 3-Clause "New" or "Revised" License
157 stars 43 forks source link

Javascript minifying is working only in first web load (just after assets folder is deleted) #42

Open dantart opened 7 years ago

dantart commented 7 years ago

Hi: Weird behaviour. I have this config:

            'class' => '\skeeks\yii2\assetsAuto\AssetsAutoCompressComponent',
            'enabled' => true,
            'readFileTimeout' => 3000, //Time in seconds for reading each asset file

            'cssCompress' =>                    true, //Enable minification css in html code
            'cssFileCompile' =>                 true, //Turning association css files
            'cssFileRemouteCompile' =>          true, //Trying to get css files to which the specified path as the remote file, skchat him to her.
            'cssFileCompress' =>                false,  //Enable compression and processing before being stored in the css file
            'cssFileBottom' =>                  true, //Moving down the page css files
            'cssFileBottomLoadOnJs' =>          true, //Transfer css file down the page and uploading them using js

            'jsCompress' =>                     true, //Enable minification js in html code
            'jsCompressFlaggedComments' =>      true, //Cut comments during processing js
            'jsFileCompile' =>                  true, //Turning association js files
            'jsFileRemouteCompile' =>           true, //Trying to get a js files to which the specified path as the remote file, skchat him to her.
            'jsFileCompress' =>                 false, //Enable compression and processing js before saving a file
            'jsFileCompressFlaggedComments' =>  false, //Cut comments during processing js

            'htmlCompress' => true, //Enable compression html
            'htmlCompressOptions' => //options for compressing output result
            [
                'extra' => true, //use more compact algorithm
                'no-comments' => true, //cut all the html comments
            ],

1) I start the test deleting my assets folder 2) I load the page and I see that js-compress files are created and in the source code I see just one call to a big js (minified of all my original js) 3) I reload the page and then I see my dozens of js loaded as minified would have not worked 4) Just if I delete again the assets folder, then the minified version is created correctly

So, it's just working JUST AFTER deleting the assets folder ... if there's something already created in the folder, it will not minified.

I have tried with other configuration, even turning everything off and just turn on the jsCompress. Same behaviour

Thank you for any help!

rankovic commented 6 years ago

I have exactly the same problem

@dantart did you found any solution?

skeeks-semenov commented 6 years ago

Try to configure in your project:

'components' => [
    'assetManager' => [
        'appendTimestamp' => true,
    ]
]
rankovic commented 6 years ago

Thanks for your quick reply... That didn't help, I'm using old version and had to change few lines in AssetsAutoCompressComponent.php