@@ -14,16 +14,23 @@ if (typeof(require) !== 'undefined') { var tree = require('less/tree') }
14
14
tree . Import = function Import ( path , imports ) {
15
15
var that = this ;
16
16
17
+ this . _path = path ;
18
+
17
19
// The '.less' extension is optional
18
20
if ( path instanceof tree . Quoted ) {
19
21
this . path = / \. ( l e ? | c ) s s $ / . test ( path . content ) ? path . content : path . content + '.less' ;
20
22
} else {
21
23
this . path = path . value . content || path . value ;
22
24
}
23
25
24
- imports . push ( this . path , function ( root ) {
25
- that . root = root ;
26
- } ) ;
26
+ this . css = / c s s $ / . test ( this . path ) ;
27
+
28
+ // Only pre-compile .less files
29
+ if ( ! this . css ) {
30
+ imports . push ( this . path , function ( root ) {
31
+ that . root = root ;
32
+ } ) ;
33
+ }
27
34
} ;
28
35
29
36
//
@@ -36,16 +43,26 @@ tree.Import = function Import(path, imports) {
36
43
// ruleset.
37
44
//
38
45
tree . Import . prototype = {
39
- toCSS : function ( ) { return "" } ,
46
+ toCSS : function ( ) {
47
+ if ( this . css ) {
48
+ return "@import " + this . _path . toCSS ( ) + ';\n' ;
49
+ } else {
50
+ return "" ;
51
+ }
52
+ } ,
40
53
eval : function ( ) {
41
- for ( var i = 0 ; i < this . root . rules . length ; i ++ ) {
42
- if ( this . root . rules [ i ] instanceof tree . Import ) {
43
- Array . prototype
44
- . splice
45
- . apply ( this . root . rules ,
46
- [ i , 1 ] . concat ( this . root . rules [ i ] . eval ( ) ) ) ;
54
+ if ( this . css ) {
55
+ return this ;
56
+ } else {
57
+ for ( var i = 0 ; i < this . root . rules . length ; i ++ ) {
58
+ if ( this . root . rules [ i ] instanceof tree . Import ) {
59
+ Array . prototype
60
+ . splice
61
+ . apply ( this . root . rules ,
62
+ [ i , 1 ] . concat ( this . root . rules [ i ] . eval ( ) ) ) ;
63
+ }
47
64
}
65
+ return this . root . rules ;
48
66
}
49
- return this . root . rules ;
50
67
}
51
68
} ;
0 commit comments