-->

Foundation5 with Compass and Assetic in Symfony2

2019-02-18 02:09发布

问题:

I want to config Foundation5 with Compass and Assetic in Symfony2, I have installed foundation as they say at http://foundation.zurb.com/docs/sass.html :

npm install -g bower grunt-cli
gem install foundation

In config.yml have configured in this way :

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        compass: 
            require: ['zurb-foundation']
            apply_to: ".(scss|sass)$"

Then I have imported in a base SCSS file @import "foundation"; but when I run : php app/console assetic:dump I have the following error :

[Assetic\Exception\FilterException]                                                                                           
  An error occurred while running:                                                                                              
  '/usr/bin/ruby' '/usr/bin/compass' 'compile' '/tmp' '--images-dir' '/srv/www/vhosts/proj/app/../src/pro/MainB  
  undle/Resources/public/images' '--config' '/tmp/assetic_compass0NW1Qc' '--sass-dir' '' '--css-dir' '' '/tmp/assetic_compassT  
  0AFvM.scss'                                                                                                                   
  Error Output:                                                                                                                 

  Output:                                                                                                                       
     create web/sprites/flags-s566f9ef717.png                                                                                   
     create web/sprites/flags-s566f9ef717.png                                                                                   
      error assetic_compassT0AFvM.scss (Line 7: File to import not found or unreadable: foundation.                             
  Load paths:                                                                                                                   
    /tmp                                                                                                                        
    /usr/share/compass/frameworks/blueprint/stylesheets                                                                         
    /usr/share/compass/frameworks/compass/stylesheets                                                                           
    /srv/www/vhosts/proj/src/pro/MainBundle/Resources/public/css                                                 
    /srv/www/vhosts/proj/src/pro/CompanyBundle/Resources/public/css                                              
    /srv/www/vhosts/proj/web/bundles/pro/css                                                                 
    Compass::SpriteImporter)                                                                                                    
     create assetic_compassT0AFvM.css                                                                                           
  Input:                                                                                                                        
  @import "base";                                                                                                               
  @import "header";                                                                                                             
  @import "global";                                                                                                             
  @import "foundation"; 

I saw also the upgrading page http://foundation.zurb.com/docs/upgrading.html where they say to change :

require "zurb-foundation"

to:

add_import_path "bower_components/foundation/scss"

However is not working, do you have any suggestions of how to configure this in order to work properly?


Change in configuration

If I change in config.yml instead of require I use plugins :

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        compass: 
            plugins: ['zurb-foundation']
            apply_to: ".(scss|sass)$"

I get this error :

  [Assetic\Exception\FilterException]                                                                                           
  An error occurred while running:                                                                                              
  '/usr/bin/ruby' '/usr/bin/compass' 'compile' '/tmp' '--images-dir' '/srv/www/vhosts/proj/app/../src/pro/MainB  
  undle/Resources/public/images' '--config' '/tmp/assetic_compass0qewOn' '--sass-dir' '' '--css-dir' '' '/tmp/assetic_compassQ  
  uKtrw.scss'                                                                                                                   
  Error Output:                                                                                                                 
  LoadError on line ["36"] of /usr/lib/ruby/1.9.1/rubygems/custom_require.rb: cannot load such file -- zurb-foundation          
  Run with --trace to see the full backtrace                                                                                    
  Input:                                                                                                                        
  @import "base";                                                                                                               
  @import "header";                                                                                                             
  @import "global";                                                                                                             
  @import "foundation";

回答1:

Finally I have fond correct configuration in config.yml :

# Assetic Configuration assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        compass: 
            load_paths:
                 - '%kernel.root_dir%/../app/Resources/public/vendor/bower_components/foundation/scss'
            apply_to: ".(scss|sass)$"