Search code examples
csssymfonysassassetic

Merge scss and css file into one with assetic


I would like to know if it is possible to merge css and scss file into one. I use Symfony 2.7 and my config.yml look like this:

assetic:
    assets:
        main:
            inputs:
                - %kernel.root_dir%/../vendor/morrisjs/morris.js/morris.css
                - %kernel.root_dir%/../vendor/twbs/bootstrap-sass/assets/stylesheets/*
            output: 'css/main.css'
            filters:
                - sass
                - cssrewrite
    filters:
        cssrewrite: ~
        sass:
          bin: C:\Ruby21-x64\bin\sass
          apply_to: "\.scss$"

When I try to dump assets with

php app/console assetic:dump

I have an error with this because sass is trying to parse the css file. Why "apply_to" doesn't work ?

I saw this post but it dosen't help me...


Solution

  • Since you're using an apply_to parameter, I think you should explicitely remove the sass filter from your assetic stanza :

    assetic:
        assets:
            main:
                inputs:
                    - %kernel.root_dir%/../vendor/style.css
                    - %kernel.root_dir%/../vendor/sass/*
                output: 'css/main.css'
                filters:
                    - cssrewrite
        filters:
            cssrewrite: ~
            sass:
              bin: C:\Ruby21-x64\bin\sass
              apply_to: "\.scss$"
    

    See this issue for instance