packagecompressor icon indicating copy to clipboard operation
packagecompressor copied to clipboard

added asset file mapping parameter to define files which are remapped af...

Open schmunk42 opened this issue 10 years ago • 5 comments

...ter package compression.

Description and param name can still be improved ;)

schmunk42 avatar Oct 10 '13 03:10 schmunk42

Can you give an example use case here to better understand what problem this helps to solve?

mikehaertl avatar Oct 10 '13 08:10 mikehaertl

Here's the config of my current project:

'clientScript'  => array(
            'class'              => 'vendor.mikehaertl.packagecompressor.PackageCompressor',
            'coreScriptPosition' => 0, //
            'enableCompression'  => 1,
            'combineOnly'        => 1,
            'copyCssImages'      => true,
            'assetsScriptMap'    => array(
                'jquery-ui.min.js'          => false,
                'jquery.fancybox-1.3.4.js'  => false,
                'iscroll.js'                => false,
                'main.js'                   => false,
                'jquery.zoom-min.js'        => false,
                'jquery.fancybox-1.3.4.css' => false,
                'jquery-ui-bootstrap.css'   => false,
                'p3.css'                    => false,
                'flags.css'                 => false,
            ),
            'packages'           => array(
                'iscroll'            => array(
                    'basePath' => 'application.components.iscroll-widget.assets',
                    'depends'  => array(
                        'jquery',
                    ),
                    'js'       => array(
                        'iscroll.js',
                    )
                ),
                'fancybox'           => array(
                    'basePath' => 'vendor.yiiext.fancybox-widget.assets',
                    'depends'  => array(
                        'jquery',
                    ),
                    'js'       => array(
                        'jquery.fancybox-1.3.4.js',
                    ),
                    'css'      => array(
                        'jquery.fancybox-1.3.4.css',
                    )
                ),
                'language-selection' => array(
                    'basePath' => 'application.components.language-selection-widget.assets',
                    'css'      => array(
                        'flags.css',
                    )
                ),
                'frontend'           => array(
                    'depends' => array(
                        'jquery',
                        'jquery.ui',
                        'bbq',
                        'bootstrap.js',
                        'bootbox',
                        'notify',
                        'jquery-css',
                        'bootstrap-yii',
                        'iscroll',
                        'fancybox',
                        'language-selection'
                    ),
                    'baseUrl' => 'themes/frontend/compressor/',
                    'js'      => array(
                        #'../../../../app/components/google-maps-widget/assets/google.js',
                        #'../../../../app/components/iscroll-widget/assets/iscroll.js',

                        '../js/main.js',
                        '../js/zoom-master/jquery.zoom-min.js',
                    ),
                    'css'     => array(
                        '../css/p3.css',
                    )
                ),
            )
        ),

As you can see I, i.e. override jquery.fancybox-1.3.4.js/css in a package. If I'd put these files into the standard scriptMap attribute they won't also be bundled into the package. If I put the files in assetSriptMap I can bundle them, but still remap them for final output.

schmunk42 avatar Oct 10 '13 12:10 schmunk42

Should be fixed, let me know if there are problems with the other branch.

schmunk42 avatar Oct 23 '13 19:10 schmunk42

Would be an 1.1.0 btw. </erbsenzählermodus>

schmunk42 avatar Oct 23 '13 19:10 schmunk42

Before I start coding ... just some thoughts:

To finalize this feature we should add another public $blockedPackages = array(); property.

This would not register packages, when the compressor is off. Because if you define scripts in a package to override publication as a single file - like we do with the blockedScripts property when the compressor is on -, then these files get included twice. One time from asset publication and the other time from package registration.

But with the changes from my other PR We can at least "fix" this just by config settings.

schmunk42 avatar Oct 29 '13 20:10 schmunk42