Skip to content

Commit 4615b7f

Browse files
committed
Add documentation for custom importers
1 parent 549087f commit 4615b7f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

site/docs/index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ The default import path is `array("")`, which means the current directory.
6666
echo $scss->compile('@import "mixins.scss"');
6767
```
6868

69+
Besides adding static import paths, it's also possible to add custom import
70+
functions. This allows you to load paths from a database, or HTTP, or using
71+
files that SCSS would otherwise not process (such as vanilla CSS imports).
72+
73+
```php
74+
<?php
75+
require "scssphp/scss.inc.php";
76+
$scss = new scssc();
77+
$scss->addImportPath(function($path) {
78+
if (!file_exists('stylesheets/'.$path)) return null;
79+
return 'stylesheets/'.$path;
80+
});
81+
82+
// will import `stylesheets/vanilla.css'
83+
echo $scss->compile('@import "vanilla.css"');
84+
```
85+
6986
### Output Formatting
7087

7188
It's possible to customize the formatting of the output CSS by changing the

0 commit comments

Comments
 (0)