Skip to content

Commit 4dafc57

Browse files
committed
small fix
1 parent 599a345 commit 4dafc57

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

src/Module.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Module extends \yii\base\Module implements BootstrapInterface {
2828
public $assetsClearScripts = false;
2929
public $assetsAddLoader = false;
3030
public $assetsMinifyLoader = false;
31+
public $scssImportBasePath = '';
3132

3233
private $cache = null;
3334
private $basePath = null;
@@ -36,7 +37,7 @@ class Module extends \yii\base\Module implements BootstrapInterface {
3637

3738
function __construct() {
3839
$this->cache = new Cache;
39-
$this->basePath = Yii::getAlias('@app') . '/';
40+
$this->basePath = Yii::getAlias('@app') . '/';
4041
$this->webPath = Yii::getAlias('@webroot') . '/';
4142
}
4243

@@ -184,10 +185,12 @@ public function addLoader() {
184185
}
185186

186187
public function minifyCSS( &$input = array() ) {
187-
$input_css = '';
188+
$input_css = '';
189+
//$base_path = Yii::getAlias('@app') . '/';
188190

189191
if( is_array( $input ) ) {
190-
$input_css = $this-> combineFiles( $input );
192+
$input_css = $this->combineFiles( $input );
193+
//$base_path .= $this->findBasePath( $input ) . '/';
191194
} else if( is_string( $input ) ) {
192195
$input_css = $input;
193196
} else {
@@ -196,7 +199,11 @@ public function minifyCSS( &$input = array() ) {
196199
}
197200

198201
// Compile scss, if exists
202+
// yii::debug('SCSS PATH: '.$this->scssImportBasePath);
203+
// return;
204+
199205
$scss = new Compiler();
206+
$scss->setImportPaths( Yii::getAlias('@app') . '/' . $this->scssImportBasePath );
200207
$input_css = $scss->compile( $input_css );
201208

202209
// Create a new CSSmin object.
@@ -269,5 +276,28 @@ public function combineFiles( &$files = array() ) {
269276
}
270277

271278
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+
}
273303
}

0 commit comments

Comments
 (0)