Jonas Sciangula Street
Jonas Sciangula Street

Reputation: 1893

Custom content type in Symfony2 Assetic (phpless)

I'm using Phpless(0.3.0) to compile less css in Symfony(2.4.2) automatically

My files:

config_dev.yml

assetic:
    debug:          "%kernel.debug%"
    use_controller: true
    filters:
        cssrewrite: ~
        lessphp:
            apply_to: "\.less$"
            formatter: "compressed"
            preserve_comments: false

view.twig:

{% stylesheets 'application/assets/less/bootstrap.less' %}
    <link rel="stylesheet" type="text/css" href="{{ asset_url }}">
{% endstylesheets %}

So, in the response, everything is compiled.. but the content type of the generated css (that comes from symfony controller (use_controller: true)) is "text/html"

4798dcc_bootstrap_1.css GET 304  text/html login:20 0 B 320 ms  

There are any setting of workaround to return this content type as text/css? Taking into account that is the development environment, and I want avoid to generate manually the css with:

php app/console assetic:dump

Thanks!

Upvotes: 0

Views: 478

Answers (1)

venimus
venimus

Reputation: 6077

The problem might be with fos_rest catching all requests

fos_rest:
    format_listener:
        rules:
            - { path: ^/, priorities: [html], fallback_format: html, prefer_extension: false }

Add rule before that to exclude your assets

Upvotes: 2

Related Questions