wtorsi
wtorsi

Reputation: 732

Symfony Assetic Merge all files in one

Is there any ways, to merge all *.css files for example, from many layouts in one, using native Symfony Assitic Manager.

Example:

**base.html.twig**    
{% block stylesheets %}
      {% stylesheets   filter='cssrewrite,uglifycss' output='css/compiled/main.css'
      'bundles/sscore/bootstrap/css/bootstrap.css' %}
      <link rel="stylesheet" href="{{ asset_url }}"/>
      {% endstylesheets %}
{% endblock %}

**index.html.twig extends base.html.twig**    
{% block stylesheets %}

      {{ parent() }}

      {% stylesheets   filter='cssrewrite,uglifycss' output='css/compiled/main.css'
      'bundles/sscore/main.css' %}
      <link rel="stylesheet" href="{{ asset_url }}"/>
      {% endstylesheets %}
{% endblock %}

In prod env this example gives me two files, but i want one meged?

Upvotes: 2

Views: 1265

Answers (2)

Jawad
Jawad

Reputation: 95

you can use scssphp , but you will need to install (scssphp) for that.

{% stylesheets filter="scssphp" output="styles/css/default_g.css"
    "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css"
    "styles/css/myfileone.css"
    "styles/css/myfileone2.css"
    "styles/css/main.css"
    "styles/css/myfile.css"
%}
<link rel="stylesheet" href="{{ asset('styles/css/default_g.css') }}" />
{% endstylesheets %}

Upvotes: 0

qooplmao
qooplmao

Reputation: 17759

I don't think Assetic does what you are wanting it to do.

I think the easiest way to get those into the one file would be to just include the parent file in your stylesheets list and override the parent block like..

**index.html.twig extends base.html.twig**     
{% block stylesheets %}
    {% stylesheets filter='cssrewrite,uglifycss' output='css/compiled/main.css'
        'bundles/sscore/bootstrap/css/bootstrap.css'
        'bundles/sscore/main.css'
        %}
        <link rel="stylesheet" href="{{ asset_url }}"/>
    {% endstylesheets %}
{% endblock %}

Upvotes: 2

Related Questions