定制 glorpen/compass-connector-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

glorpen/compass-connector-bundle

Composer 安装命令:

composer require glorpen/compass-connector-bundle

包简介

Symfony2 bundle for AsseticCompassConnector filter

README 文档

README

This project is now DEPRECATED. Currently there are better alternatives, please use those in new projects.

GlorpenCompassConnectorBundle

The better Compass integration for Symfony2.

For forking and other funnies:

What problems is it solving?

This bundle:

  • adds bundle namespace for compass files - so you can do cross bundle imports or use assets from other bundle
    • ... and it should enable distributing bundles with compass assets
  • you don't need installed assets in your_app/web - connector uses files from eg. SomeBundle/Resources dir
  • assets recompiling/updating when any of its dependencies are modified - be it another import, inlined font file or just width: image-width(@SomeBundle:public/myimage.png);
  • for referencing files inside app/Resources dir use just @somefile.png (sprites, inline images, scss imports)

How to install

  • first, you need to install ruby connector gem:
gem install compass-connector
  • add requirements to composer.json:
{
    "require": {
        "glorpen/compass-connector-bundle": "*"
    }
}
  • enable the bundle in your AppKernel class

app/AppKernel.php

<?php

class AppKernel extends AppKernel
{
   public function registerBundles()
   {
       $bundles = array(
           ...
           new Glorpen\Assetic\CompassConnectorBundle\GlorpenCompassConnectorBundle(),
           ...
       );
   }
}
  • add assetic filter config in config.yml
assetic:
    filters:
        compass_connector:
           resource: "%kernel.root_dir%/../vendor/glorpen/compass-connector-bundle/Glorpen/Assetic/CompassConnectorBundle/Resources/config/filter.xml"
           #apply_to: ".scss$" # uncomment to auto-apply to all scss assets

If you are running into following error:

Scope Widening Injection detected: The definition "assetic.filter.compass_connector.resolver" references the service "templating.asset.default_package" which belongs to a narrower scope. Generally, it is safer to either move "assetic.filter.compass_connector.resolver" to scope "request" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "templating.asset.default_package" each time it is needed. In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.

... or if you just want to change generated assets url (for eg. CDN).

You need to add following configuration to you project (remember to change urls):

framework:
   templating:
      assets_base_urls:
         http: ["http://localhost:8000"]
         ssl: ["http://localhost:8000"]

Usage

There are five kind of "paths":

  • app: looks like @MyBundle:public/images/asset.png
  • app global: cannot be converted to URL, looks like @data/image.png and will resolve to app/Resources/data/image.png
  • absolute: starts with single /, should be publicly available, will resolve to web/
  • vendor: a relative path, should be used only by compass plugins (eg. zurb-foundation, blueprint)
  • absolute path: starts with /, http:// etc. and will NOT be changed by connector

Some examples:

@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/ */

This bundle uses Assetic and CompassConnector filter name is compass_connector.

Confguration

You can change default configuration by setting following DIC parameters:

parameters:
   assetic.filter.compass_connector.plugins:
      "zurb-foundation": ">4"
   assetic.filter.compass_connector.imports: ["/some/path"]
   assetic.filter.compass_connector.cache_path: %kernel.root_dir%/cache/compassConnector
   assetic.filter.compass_connector.compass_bin: /usr/bin/compass
   assetic.filter.compass_connector.resolver.output_dir: %kernel.root_dir%/../web/compass
   assetic.filter.compass_connector.resolver.vendor_prefix: vendors

As for assetic.filter.compass_connector.plugins you can provide arguments as a list eg. ["zurb-foundation"] or array with required gem version: {"zurb-foundation":">=4"}

统计信息

  • 总下载量: 799
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2013-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固