Skip to content
Browse files

Merge branch 'release/1.21'

* release/1.21:
  Update changelog
  Bump version to v1.21
  Move CSS @import statements to top of combined file
  • Loading branch information...
2 parents 9c206f5 + 0abf692 commit f6a9f08500b6112baa29a5dddf2011e0ff360770 @canton7 committed Feb 16, 2013
View
2 bootstrap.php
@@ -4,7 +4,7 @@
* Casset: Convenient asset library for FuelPHP.
*
* @package Casset
- * @version v1.20
+ * @version v1.21
* @author Antony Male
* @license MIT License
* @copyright 2013 Antony Male
View
4 changelog.md
@@ -3,6 +3,10 @@ Changelog
This file lists the important changes between versions. For a list of minor changes, check the log.
+v1.21
+-----
+ - Move CSS @import statements to top of combined files
+
v1.20
-----
- Update addons/readme.md to document more twig functions
View
22 classes/casset.php
@@ -4,7 +4,7 @@
* Casset: Convenient asset library for FuelPHP.
*
* @package Casset
- * @version v1.20
+ * @version v1.21
* @author Antony Male
* @license MIT License
* @copyright 2013 Antony Male
@@ -107,7 +107,7 @@ class Casset {
*/
protected static $post_load_callback = null;
- /*
+ /**
* @var function If given, the function to call when we've decided on the name
* for a file, but want to allow the user to tweak it before we write it to the
* page.
@@ -127,6 +127,11 @@ class Casset {
protected static $css_uri_rewriter = 'absolute';
/**
+ * @var Whether to move @import lines to the top
+ */
+ protected static $move_imports_to_top = true;
+
+ /**
* @var bool Wether we've been initialized.
*/
public static $initialized = false;
@@ -199,6 +204,8 @@ public static function _init()
static::$css_uri_rewriter = \Config::get('casset.css_uri_rewriter', static::$css_uri_rewriter);
+ static::$move_imports_to_top = \Config::get('casset.move_imports_to_top', static::$move_imports_to_top);
+
static::$initialized = true;
}
@@ -1191,6 +1198,17 @@ protected static function combine($type, $file_group, $minify, $inline)
}
}
}
+ if ($type == 'css' && static::$move_imports_to_top) {
+ // Remove @import lines, and record them
+ $imports = array();
+ $content = preg_replace_callback('/@import.*?;/', function($match) use (&$imports) {
+ $imports[] = $match[0];
+ return '';
+ }, $content);
+ if (count($imports))
+ $content = implode(PHP_EOL, $imports).PHP_EOL.$content;
+ }
+
file_put_contents($abs_filepath, $content, LOCK_EX);
$mtime = time();
}
View
2 classes/casset/addons/twig.php
@@ -4,7 +4,7 @@
* Casset: Convenient asset library for FuelPHP.
*
* @package Casset
- * @version v1.20
+ * @version v1.21
* @author Antony Male
* @author Derek Myers
* @license MIT License
View
2 classes/casset/csscompressor.php
@@ -17,7 +17,7 @@
* This library is used as part of Casset.
*
* @package Casset
- * @version v1.20
+ * @version v1.21
* @author Antony Male
* @license MIT License
* @link http://github.com/canton7/fuelphp-casset
View
2 classes/casset/cssurirewriter.php
@@ -10,7 +10,7 @@
* This library is used as part of Casset.
*
* @package Casset
- * @version v1.20
+ * @version v1.21
* @author Antony Male
* @license MIT License
* @link http://github.com/canton7/fuelphp-casset
View
2 classes/casset/cssurirewriterrelative.php
@@ -4,7 +4,7 @@
* This library is used as part of Casset.
*
* @package Casset
- * @version v1.20
+ * @version v1.21
* @author Antony Male
* @license MIT License
* @link http://github.com/canton7/fuelphp-casset
View
2 classes/casset/jsmin.php
@@ -52,7 +52,7 @@
/**
* This library is used as part of Casset.
* @package Casset
- * @version v1.20
+ * @version v1.21
* @author Antony Male
* @license MIT License
* @link http://github.com/canton7/fuelphp-casset
View
2 config/casset.php
@@ -3,7 +3,7 @@
* Casset: Convenient asset library for FuelPHP.
*
* @package Casset
- * @version v1.19
+ * @version v1.21
* @author Antony Male
* @license MIT License
* @copyright 2013 Antony Male
View
8 readme.md
@@ -851,6 +851,14 @@ If you decide to do this, you'll probably want to turn off Casset's rewriting.
The algorithm is specified using the `css_uri_rewriter` config key.
This can take values of 'absolute', 'relative', or 'none'.
+CSS @import rewriting
+---------------------
+
+CSS `@import` statements need to come at the beginning of the file in which they appear.
+Combining files obviously screws this up, as lines which were at the beginning of a file could now be somewhere in the middle of the combined file.
+If the config key `move_imports_to_top` is true (the default) then casser will take all `@import` lines and move them to the top of the combined file.
+If this is causing problems, you can disable this feature.
+
Addons
------

0 comments on commit f6a9f08

Please sign in to comment.
Something went wrong with that request. Please try again.