glorpen / assetic-compass-connector
Assetic Compass 过滤器
v0.2.3
2016-08-13 13:05 UTC
Requires
- php: >=5.3.1
- kriswallsmith/assetic: *
- symfony/finder: 2.*
Requires (Dev)
README
此项目现已废弃。目前有更好的替代方案,请在新项目中使用这些方案。
Glorpen AsseticCompassConnector
更好的PHP项目Compass集成。
关于分支和其他有趣的事情
- https://bitbucket.org/glorpen/asseticcompassconnector
- https://github.com/glorpen/AsseticCompassConnector
它解决了哪些问题?
此Assetic过滤器
- 提供了一种将Compass与任何框架紧密集成的途径 - 您只需为项目编写简单的Resolver
- 为compass文件添加了bundle/plugins/package命名空间 - 因此您可以执行跨插件导入或使用其他包的资产
- ...并且它可以使分发包含Compass资产的捆绑包成为可能
- 您的Resolver提供所需的文件 - 因此它可以支持任何项目结构
- 当任何依赖项被修改时(无论是另一个导入、内联字体文件还是简单的
width: image-width(@SomeBundle:public/myimage.png);
),资产会重新编译/更新
可用的Resolver
如何安装
- 首先,您需要安装ruby连接器gem
gem install compass-connector
- 将要求添加到composer.json中
{ "require": { "glorpen/assetic-compass-connector": "*" } }
虚拟路径
有四种类型的“路径”
- app: 形似
@MyBundle:public/images/asset.png
- 绝对路径:以单个
/
开头,应仅用于磁盘文件解析和URL前缀,它始终是公共文件 - vendor: 一个相对路径,应仅由compass插件(例如zurb-foundation,blueprint)使用
- 绝对路径:以
//
、http://
等开头,并且连接器不会修改它
一些示例
@import "@SomeBundle:scss/settings"; /* will resolve to src/SomeBundle/Resources/scss/_settings.scss */ @import "foundation"; /* will include foundation scss from your compass instalation */ width: image-size("@SomeBundle:public/images/my.png"); /* will output image size of SomeBundle/Resources/public/images/my.png */ background-image: image-url("@SomeBundle:public/images/my.png"); /* will generate url with prefixes given by Symfony2 config */ @import "@SomeBundle:sprites/*.png"; /* will import sprites located in src/SomeBundle/Resources/sprites/ */
用法
此过滤器的Assetic名称是compass_connector
。
您可以根据任何Assetic过滤器的编译方式编译资产
<?php use Glorpen\Assetic\CompassConnectorFilter\Filter; use Glorpen\Assetic\CompassConnectorFilter\Resolver\SimpleResolver; use Assetic\Asset\AssetCollection; use Assetic\Asset\FileAsset; $resolver = new SimpleResolver( "ResourcesDir/", "outputDir/" ); $f = new Filter($resolver, 'path/to/cache', 'path/to/compass/bin'); $f->setPlugins(array("zurb-foundation")); //or array("zurb-foundation"=>">4") $f->addImport('/path/to/some/scss/dir'); //and then @import "scss_in_some_dir"; $css = new AssetCollection(array( new FileAsset('path/to/file.scss'), ), array( $f ));