kevbaldwyn / css-path-rewrite
Rewrite paths in css files, includes a filter for Assetic
Installs: 1 489
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=5.3.3
- kriswallsmith/assetic: 1.*
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2024-12-17 05:02:18 UTC
README
Rewrite paths in css files to things like images from local to remote (or anything else). Currently only handles "root relative" url paths, ie urls that start with /
.
##Installation With Composer
"require": {
...
"kevbaldwyn/css-path-rewrite":"0.*"
...
}
Composer Update:
$ composer update kevbaldwyn/css-path-rewrite
##Usage To simply rewrite urls in a css file:
$cssFileContent = file_get_contents('/path/to/my/file.css');
$writer = new KevBaldwyn\CssPathRewrite\Rewriter($cssFileContent, 'http://www.example.com');
$output = $writer->rewrite();
file_put_contents('/path/to/my/file.css', $output);
Or if using assetic simply include in your filters array:
$css = new AssetCollection(array(
new FileAsset('/path/to/src/styles.less', array(new LessFilter())),
new GlobAsset('/path/to/css/*'),
), array(
new KevBaldwyn\CssPathRewrite\Assetic\Filter('http://www.example.com'),
));