ericmckean / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add doc for 'postprocessor' option #164

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Because there is no a server import feature I want to be able to remove the
@import on the fly

(currently several domains share stylesheets, and I want to test minify on
only one of them, if I can get minify to remove the imports I can use the
two methods side by side)

Please use labels and text to provide additional information.

I have attempted this myself by:

- adding $min_serveOptions['removeCssImports'] = true;  to the config.php
- adding ,self::$_options['removeCssImports'] into the return of the
_getCacheId() method of Minify
- adding 
        }else if(self::$_options['removeCssImports']) {
            preg_match_all('/@import.*?;/', $css, $imports);
            $css = preg_replace('/@import.*?;/', '', $css);

into the _handleCssImports method of Minify

This seems to work a treat... is there any problems with this? and Can it
be added to future releases to save me updating my code every time there is
an update? :-)

Original issue reported on code.google.com by stevewhi...@gmail.com on 25 Mar 2010 at 10:56

GoogleCodeExporter commented 9 years ago
You can instead rely on an undocumented feature that applies a function after
minification. In config.php:

function postMin($content, $type) {
    return ($type === 'text/css')
       ? preg_replace('/@import.*?;/', '', $content)
       : $content;
}
$min_serveOptions['postprocessor'] = 'postMin';

I'll mention this in the wiki.

Original comment by mrclay....@gmail.com on 25 Mar 2010 at 1:24

GoogleCodeExporter commented 9 years ago
Added in R402

Original comment by mrclay....@gmail.com on 25 Mar 2010 at 1:50