Compass workflow and structure with multiple input/otput pathes in PhpStorm

Hi, List.

I've spent a few days to configure a workflow within phpStrom and Compass usage.

Our project structure is divided on so-called extensions, where each extension is on same tree level and has it's own "Resources" folder with subfolders "Private/Sass" for .scss files and "Public/Css" for generated .css result.

Besicly, something like this:

root
|-- extensions
    |-- ext1
        |-- Resources
            |-- Public
            |-- Private
    |-- ext2
        |-- Resources
            |-- Public
            |-- Private
   |-- ext3
        |-- Resources
            |-- Public
            |-- Private
   ...


Previously we were using raw Scss with PhpStorm's file watcher, which worked fine with follwong configuration

--no-cache --update $FileDir$\$FileName$:..\..\Public\Css\$FileNameWithoutExtension$.css --unix-newlines


Now we decided to use Compass and here my problems appeared.
As I understand, due to Compass nature it is not possible to have multiple input/output pathes configured, because Compass operates single folders, defined in config.rb in project root.

After multiple tries and errors I found two almsot good solutions, but none of them is perfect.


First solution
If we thik of Compass just as a library for Sass, we can still use scss compiler, but with option --compass
So, at the end we can still continue using Scss file watcher, but wit ha bit modified configuration

--update $FileDir$\$FileName$:..\..\Public\Css\$FileNameWithoutExtension$.css --unix-newlines --compass

You may notice, that I've removed --no-cache parameter - this is done due to performance reasons, since every @import "compass"; added about +5 seconds to compilation time and I don't mind about having .sass-cache folders in my local filesystem and project.
All the Compass features (including sprites generation) are available
But disadvantage is, that I'm loosing full power of compass compilation CLI (i.e. -e option). Also I'm not sure, if I later need some compass addon (like "susy" framework), taht it'll work smoothly.
Also I need config.rb in each folder and subfolder, that contains Scss and it must contain at least valid "images_dir" to be able to load images and generate sprites. However, "css_dir" and "sass_dir" as well as other useful options, like "output_style" are ignored.


Second solution
After giving a chance to Scss watcher, I came back again to "scss compass" watcher.
Here I ebded up with creating separate watchers for each extension.
Therefore I need separate "config.rb" placed in each "Resources" directory and one "config.rb" in the root of my project to put it's path into "Compass support" -> "Config path" configuration. The latter is just a dummy, since it is used nowhere by compass - instead it uses those config files in "Resources".
So, each of my watchers contains such arguments:

compile $ProjectFileDir$/extensions/ext1/Resources

And such working directory

$ProjectFileDir$/extensions/ext1/Resources

Thie perfectly fits the structure, becasue then compass thinks of each "Resources" folder as of project root.
But seems, that phpStorm has complains about such a way.
It gives me a hint to add "compass scss" file watcher for each of my .scss file and on each file save it triggers all of created compass scss file watchers, which is not desired behaviour.


Does someone have similiar issue and solution to it?

5 comments

>It gives me a hint to add "compass scss" file watcher for each of my  .scss file and on each file save it triggers all of created compass scss  file watchers, which is not desired behaviour.


You can press Dismiss to stop these hints to appear. As for watchers triggering, I can suggest creating custom scopes (1 for each of your "Resources" directories) including these directories only, and set these scopes to your file watchers, so that each watcher listens to changes made to .scss files in its own scope and not to all .scss files in project

0

Hi, Elena.

Many thanks for your suggestion - custom scopes solves the problem!

But still it would be nice for phpStorm to support multiple Compass projects within one phpStorm's project and have single file watcher for them all.
Maybe, it may be useful to remove "Config path:" from "Compass Support" tab and allow phpStorm to search for config.rb recursively from current point till the project root, until it finds one. Then file watcher can include one more variable $SourcePathRealtiveToProjectRoot$, so at the end compass arguments list may look like:

compile $UnixSeparators($ProjectFileDir$)$/$SourcePathRealtiveToProjectRoot$


Same for working directory:

$ProjectFileDir$/$SourcePathRealtiveToProjectRoot$


And output path to refresh:

$ProjectFileDir$/$SourcePathRealtiveToProjectRoot$/Public/Css


Regards.

0

Please feel free to create a request for this feature in youtrack,http://youtrack.jetbrains.com/issues/WEB

0

I've found almost similar issue and added comment with vote.
For anyone else, intersting in this topic, please find the issue here: http://youtrack.jetbrains.com/issue/WEB-9832

0

Please sign in to leave a comment.