最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Sass bundle with Symfony : import issue - Stack Overflow

matteradmin7PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far