[GH-ISSUE #1335] Cannot set $flag-icons-included-countries variable with @use #602

Closed
opened 2026-03-03 14:39:40 +03:00 by kerem · 2 comments
Owner

Originally created by @kristofdho on GitHub (Feb 25, 2025).
Original GitHub issue: https://github.com/lipis/flag-icons/issues/1335

Proper way to set the $flag-icons-included-countries variable with the @use sass directive instead of the @import directive is like this:

@use 'flag-icons/sass/flag-icons' with (
  $flag-icons-included-countries: 'us' 'de' 'fr' 'es'
);

However this fails with following error:

./src/app/example.component.scss?ngResource - Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
This variable was not declared with !default in the @used module.
  ╷
5 │   $flag-icons-included-countries: 'us' 'de' 'fr' 'es'
  │   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  src\app\example.component.scss 5:3  root stylesheet


error Command failed with exit code 1.

So for now we're stuck using it like this:

$flag-icons-included-countries: 'us' 'de' 'fr' 'es';
@import 'flag-icons/sass/flag-icons';

which achieves the desired result, but forces us to keep using @import.

In order to resolve the issue, $flag-icons-included-countries should be properly defined as a variable, just like e.g. $flag-icons-use-square.

Originally created by @kristofdho on GitHub (Feb 25, 2025). Original GitHub issue: https://github.com/lipis/flag-icons/issues/1335 Proper way to set the `$flag-icons-included-countries` variable with the `@use` sass directive instead of the `@import` directive is like this: ```scss @use 'flag-icons/sass/flag-icons' with ( $flag-icons-included-countries: 'us' 'de' 'fr' 'es' ); ``` However this fails with following error: ``` ./src/app/example.component.scss?ngResource - Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): This variable was not declared with !default in the @used module. ╷ 5 │ $flag-icons-included-countries: 'us' 'de' 'fr' 'es' │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ╵ src\app\example.component.scss 5:3 root stylesheet error Command failed with exit code 1. ``` So for now we're stuck using it like this: ```scss $flag-icons-included-countries: 'us' 'de' 'fr' 'es'; @import 'flag-icons/sass/flag-icons'; ``` which achieves the desired result, but forces us to keep using `@import`. In order to resolve the issue, `$flag-icons-included-countries` should be properly defined as a variable, just like e.g. `$flag-icons-use-square`.
kerem closed this issue 2026-03-03 14:39:40 +03:00
Author
Owner

@lipis commented on GitHub (Feb 26, 2025):

We're working on it and there is an issue with @use and @imports (#1324)

<!-- gh-comment-id:2685576592 --> @lipis commented on GitHub (Feb 26, 2025): We're working on it and there is an issue with @use and @imports (#1324)
Author
Owner

@kristofdho commented on GitHub (Feb 26, 2025):

Hi, thank you for the swift reply.
I found these PRs as well, but they do not add a proper variable declaration for $flag-icons-included-countries yet, which is why I created this issue.

<!-- gh-comment-id:2686056144 --> @kristofdho commented on GitHub (Feb 26, 2025): Hi, thank you for the swift reply. I found these PRs as well, but they do not add a proper variable declaration for `$flag-icons-included-countries` yet, which is why I created this issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/flag-icons#602
No description provided.