admin管理员组

文章数量:1434388

I am using the Sass bundle (.html) for Symfony.

I have a file assets/styles/front/main/contenus.scss:

@import "../variables.scss";

.test { 
  color: $c-primary; 
}

.video {
  height: 240px;
}

I include it in my rechercher.html.twig view like this:

{% block stylesheets %}
    <link rel="stylesheet" href="{{ asset('styles/front/main/contenus.scss') }}">
{% endblock %}

The code related to the .video class is interpreted correctly, but I get a console error in the browser stating that the variables.scss file is "not found":

GET https://127.0.0.1:8000/assets/styles/front/variables net::ERR_ABORTED 404 (Not Found)

However, the _variables.scss file is indeed present in /assets/styles/front/.

How can I import it?

I am using the Sass bundle (https://symfony/bundles/SassBundle/current/index.html) for Symfony.

I have a file assets/styles/front/main/contenus.scss:

@import "../variables.scss";

.test { 
  color: $c-primary; 
}

.video {
  height: 240px;
}

I include it in my rechercher.html.twig view like this:

{% block stylesheets %}
    <link rel="stylesheet" href="{{ asset('styles/front/main/contenus.scss') }}">
{% endblock %}

The code related to the .video class is interpreted correctly, but I get a console error in the browser stating that the variables.scss file is "not found":

GET https://127.0.0.1:8000/assets/styles/front/variables net::ERR_ABORTED 404 (Not Found)

However, the _variables.scss file is indeed present in /assets/styles/front/.

How can I import it?

Share Improve this question edited Nov 19, 2024 at 13:24 Alan asked Nov 18, 2024 at 10:47 AlanAlan 1351 gold badge3 silver badges14 bronze badges 3
  • According to the docs you have to point your {{ asset() }} to the .scss file, not the css file. So it would be {{ asset('assets/styles/front/main/contenus.scss') }} – Julian Koster Commented Nov 18, 2024 at 11:53
  • @JulianKoster Sorry, that's what i do, i've edited my question. I point to contenu.scss and i get the error :) – Alan Commented Nov 19, 2024 at 13:23
  • What is the output of php bin/console sass:build? And did you exclude scss from AssetMapper? – Michael Sivolobov Commented Nov 19, 2024 at 16:49
Add a comment  | 

1 Answer 1

Reset to default 1

Try it withouth the extension, so just @import "../variables";

And if You have the contenus.css file too, check if the variable file's content is in there or not.

本文标签: Sass bundle with Symfonyimport issueStack Overflow