node-sass-json-importer icon indicating copy to clipboard operation
node-sass-json-importer copied to clipboard

Override value from one json by value from another json

Open Frimlik opened this issue 3 years ago • 0 comments

Hi, I'm mixing Angular project with bootstrap lib and would like to have in my Angular project two theme files, one with default values, another with custom values, like this: theme-colors-default.json

{  
  "colors": {
    "primaryColor": "yellow",
    "secondaryColor": "blue"
  }
}

theme-colors-custom.json

{
  "colors": {
    "primaryColor": "green"
  }
}

Then I have a style file, where I import both themes with help of node-sass-json-importer. _variables.scss

@import 'src/themes/theme-colors-default.json';
@import 'src/themes/theme-colors-custom.json';

$primary = $primary-color

Now, if I access map-get($colors, 'secondary-color'), I get default bootstrap color (I suppose because first json is overwritten by second totally and thus secondaryColor is missing). Is it somehow possible to arrange some kind of 'overriding', to override only values present in custom theme?

The only way I can see now is to copy the default theme and change only values that need to be changed, but I don't like this way very much.

Thanks.

Frimlik avatar Apr 14 '21 15:04 Frimlik