Graupl / graupl

The Graupl mono-repo.
1 stars 0 forks source link

Bug: Cannot forward multiple defaults files to overriding #23

Closed NickDJM closed 2 months ago

NickDJM commented 2 months ago

Summary

When you try to forward multiple defaults files to override variables during sass compiling, you get the following error:

Error: This module was already loaded, so it can't be configured using "with".

Steps to reproduce

Have a setup like so:

@forward "init";

@forward "defaults" with(
  $prefix: "custom",
);

@forward "theme/defaults" with(
  $custom-colors: (
    success: (
      100: #f0fff4,
      200: #c6f6d5,
      300: #9ae6b4,
      400: #68d391,
      500: #48bb78,
      600: #38a169,
      700: #2f855a,
      800: #276749,
      900: #22543d,
    ),
  ),
);

// Forward all layers.
@forward "base";
@forward "layout";
@forward "component";
@forward "state";
@forward "theme";
@forward "utilities";

Run npm run build and get an error.

Expected Behaviour

You should be able to overwrite the prefix and custom colours (and any other default in any other file) at the same time.

Additional context

Looks like this might be a sass restriction. Might need to change the names of the defaults files to be scoped to their appropriate components (e.g. themes/theme-defaults, root-defaults, button-defaults).