braincrafted / bootstrap-bundle

BraincraftedBootstrapBundle integrates Bootstrap into Symfony2 by providing templates, Twig extensions, services and commands.
http://bootstrap.braincrafted.com
MIT License
399 stars 182 forks source link

Use bootstrap.scss directly in stylesheets block of a twig template #446

Closed TiMESPLiNTER closed 8 years ago

TiMESPLiNTER commented 8 years ago

I like to merge all my CSS files and JS files into one big file. For this have the following code in my base twig template:

    {% stylesheets filter="?scssphp" output="css/app.css"
        '@BraincraftedBootstrapBundle/Resources/sass/bootstrap.scss'
        '@PinanoSelect2Bundle/Resources/public/css/select2.css'
        '@AppBundle/Resources/public/css/site.css'
    %}

and

    {% javascripts filter="?jsqueeze" output="js/app.js"
        '@AppBundle/Resources/public/js/jquery.js'
        '@BraincraftedBootstrapBundle/Resources/js/bc-bootstrap-collection.js'
        '@AppBundle/Resources/public/js/site.js'
    %}

while the javascript part works perfectly the css part don't. The boostrap.scss gets compiled into a css file. But the imports never get imported. The resultung CSS file looks like this:

// Core variables and mixins
@import "../../../../../../../twbs/bootstrap-sass/assets/stylesheets/bootstrap/variables";
@import "../../../../../../../twbs/bootstrap-sass/assets/stylesheets/bootstrap/mixins";

// and so on

don't know if this is a problem of the bundle itself or if it even should support this...

And yes I have the registered a SASS compiler:

# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ AppBundle, BraincraftedBootstrapBundle ]
    filters:
        cssrewrite: ~
        scssphp: ~
        jsqueeze: ~

Okay actually the problem is the ? in {% stylesheets filter="?scssphp" so it only gets compiled in debug-off envs. When I remove the questionmark it tries to compile but fails with

[exception] 500 | Internal Server Error | Symfony\Component\Debug\Exception\ContextErrorException
[message] Notice: Array to string conversion
[1] Symfony\Component\Debug\Exception\ContextErrorException: Notice: Array to string conversion
    at n/a
        in /htdocs/project/vendor/leafo/scssphp/src/Compiler.php line 2160

While assetic:dump --env=prod tells me:

 [RuntimeException]                                                                                                                                
  The source file "/htdocs/project/app/../vendor/twbs/bootstrap-sass/assets/stylesheets/_bootstrap.scss" does not exist.  

and yes it does not exists. There's only a boostrap.scss file without _.

TiMESPLiNTER commented 8 years ago

Okay nevermind somehow my _bootstrap.scss file got renamed to bootstrap.scss in the external dependecy. Don't know how that happened.