@@ -28,6 +28,7 @@ class Module extends \yii\base\Module implements BootstrapInterface {
28
28
public $ assetsClearScripts = false ;
29
29
public $ assetsAddLoader = false ;
30
30
public $ assetsMinifyLoader = false ;
31
+ public $ scssImportBasePath = '' ;
31
32
32
33
private $ cache = null ;
33
34
private $ basePath = null ;
@@ -36,7 +37,7 @@ class Module extends \yii\base\Module implements BootstrapInterface {
36
37
37
38
function __construct () {
38
39
$ this ->cache = new Cache ;
39
- $ this ->basePath = Yii::getAlias ('@app ' ) . '/ ' ;
40
+ $ this ->basePath = Yii::getAlias ('@app ' ) . '/ ' ;
40
41
$ this ->webPath = Yii::getAlias ('@webroot ' ) . '/ ' ;
41
42
}
42
43
@@ -184,10 +185,12 @@ public function addLoader() {
184
185
}
185
186
186
187
public function minifyCSS ( &$ input = array () ) {
187
- $ input_css = '' ;
188
+ $ input_css = '' ;
189
+ //$base_path = Yii::getAlias('@app') . '/';
188
190
189
191
if ( is_array ( $ input ) ) {
190
- $ input_css = $ this -> combineFiles ( $ input );
192
+ $ input_css = $ this ->combineFiles ( $ input );
193
+ //$base_path .= $this->findBasePath( $input ) . '/';
191
194
} else if ( is_string ( $ input ) ) {
192
195
$ input_css = $ input ;
193
196
} else {
@@ -196,7 +199,11 @@ public function minifyCSS( &$input = array() ) {
196
199
}
197
200
198
201
// Compile scss, if exists
202
+ // yii::debug('SCSS PATH: '.$this->scssImportBasePath);
203
+ // return;
204
+
199
205
$ scss = new Compiler ();
206
+ $ scss ->setImportPaths ( Yii::getAlias ('@app ' ) . '/ ' . $ this ->scssImportBasePath );
200
207
$ input_css = $ scss ->compile ( $ input_css );
201
208
202
209
// Create a new CSSmin object.
@@ -269,5 +276,28 @@ public function combineFiles( &$files = array() ) {
269
276
}
270
277
271
278
return $ buf ;
272
- }
279
+ }
280
+
281
+ public function findBasePath ( &$ paths = [] )
282
+ {
283
+ $ base = FALSE ;
284
+
285
+ foreach ( $ paths as $ path ) {
286
+ $ pos_win = strrpos ( $ path , '\\' );
287
+ $ pos_win = $ pos_win === FALSE ? 999 : $ pos_win ;
288
+
289
+ $ pos_lin = strrpos ( $ path , '/ ' );
290
+ $ pos_lin = $ pos_lin === FALSE ? 999 : $ pos_lin ;
291
+
292
+ $ pos = min ( $ pos_win , $ pos_lin );
293
+
294
+
295
+ $ path_base = substr ( $ path , 0 , $ pos );
296
+ if ( $ base === FALSE or strlen ( $ path_base ) < strlen ( $ base ) ) {
297
+ $ base = $ path_base ;
298
+ }
299
+ }
300
+
301
+ return $ base ;
302
+ }
273
303
}
0 commit comments