[Extension] Yii-Sass - Sass (Scss) And Compass Support

I developed this extension which allows you to use Sass (SCSS) and Compass easily in your Yii projects:

http://www.yiiframework.com/extension/sass/

Extension can do the following:

  • compile SCSS files on-the-fly

  • publish compiled CSS files

  • register published CSS files

External Sass tools are NOT used, compilation is done using PHP compiler.

This extension caches compiled CSS code and prevents recompilation if there is no need in it.

A few words about Sass and Compass:

Sass is an extension of CSS that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly.

Compass is an open-source CSS authoring framework which uses the Sass stylesheet language to make writing stylesheets powerful and easy.

Feel free to post your thoughts and comments!

Version 1.1.0 is released (2014-01-07)

Changes:

  • Allow to register and publish compiled CSS files inside specific published directory to allow using of relative references in CSS for images, fonts and other published files

  • Add compilerOutputFormatting component option, allow to switch between simple, nested and compressed (Pavel Volyntsev)

  • Change default value of the writableDirectoryPermissions component option from 0644 to 0777. It should prevent permission errors on some Linux servers

  • Update code style and documentation

Extension page: http://www.yiiframework.com/extension/sass/

Version 1.2.0 is released (2014-08-12)

Changes:

  • Fix compatibility with the new 0.1 version of the scssphp compiler (alexdevid)

  • Set minimum required PHP version to 5.3 because the new version of scssphp compiler requires it

  • Add new formatting type SassHandler::OUTPUT_FORMATTING_CRUNCHED which can be used with compilerOutputFormatting parameter (alexdevid)

  • Add unit tests to check integration with scssphp compiler and with scssphp-compass library

  • Fix a bug: $hashByName=true argument wasn’t properly passed to the Yii’s asset manager

  • Minor fixes and improvements

Extension page: http://www.yiiframework.com/extension/sass/

Version 1.3.0 is released (2015-02-21)

Changes:

  • Fix CAssetManager::publish() call - pass $hashByName value used in Yii::app()->sass->publish() and Yii::app()->sass->register() methods

  • Remove deprecated PHPUnit "strict" setting

  • Do not use unstable (dev-master) version of scssphp compiler anymore when Composer is used to install yii-sass extension

  • Make installation via Composer easier - "minimum-stability" setting is not needed anymore

  • Add "writableFilePermissions" option (defaults to 0666), fix file permissions issues with certain umask settings in OS by calling chmod for created/updated files, always call chmod for writable directories

  • Add “defaultHashByName” setting which allows to set a default “$hashByName” value for all plugin’s methods

  • Add more information to exceptions’ messages

  • Enable Travis CI builds

  • Update documentation

Extension page: http://www.yiiframework.com/extension/sass/

Version 2.0.0 is released (2017-05-01)

Changes:

  • Update scssphp compiler to version ~0.6.7

  • Minimum required PHP version is changed to >= 5.4.0

  • Allow to use custom Yii caching components by configuring "cacheComponentId" option

Extension page: http://www.yiiframework.com/extension/sass/

how to use


compass watch

Another question, why it always create hex folder without deleting the existing one.

How can I modify the output path folder?

Sarath.U, yii-sass doesn’t use original compass compiler.

If you want to use compass watch then you should configure your application separately.

But it doesn’t make much sense to use both: yii-sass and compass, you probably want to choose one tool.

A new directory is created for new version of files to avoid caching issues.

The output directory is controlled by Yii assetManager, you should configure it accordingly if you want to use another directory.

Hi

I have exception when register my scss file




Can not write the compiled CSS file: /home/test/dev.local/gift/assets/front/styles/compiled/core-7f7e5340.css



into my main Controller method init i put this code




 Yii::app()->sass->register(

            Yii::getPathOfAlias('webroot.assets.front.styles') . DIRECTORY_SEPARATOR . 'core.scss'

        );



technokid, one of the solutions in your case is to explicitly update directory permissions to allow writing into it

Version 2.0.1 is released (2017-11-09)

Changes:

  • #15: Fix an error with the compilation of empty files (tomaszbrunarski)

Extension page: http://www.yiiframework.com/extension/sass/