-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow passing Filesystem volumes to SD instance / extend method
- Loading branch information
1 parent
220bc88
commit 42c8345
Showing
27 changed files
with
320 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
'style-dictionary': minor | ||
--- | ||
|
||
Allow passing a custom FileSystem Volume to your Style-Dictionary instances, to ensure input/output files are read/written from/to that specific volume. | ||
Useful in case you want multiple Style-Dictionary instances that are isolated from one another in terms of inputs/outputs. | ||
|
||
```js | ||
import { Volume } from 'memfs'; | ||
|
||
const vol = new Volume(); | ||
|
||
const sd = new StyleDictionary({ | ||
tokens: { | ||
colors: { | ||
red: { | ||
value: "#FF0000", | ||
type: "color" | ||
} | ||
} | ||
}, | ||
platforms: { | ||
css: { | ||
transformGroup: "css", | ||
files: [{ | ||
destination: "variables.css", | ||
format: "css/variables" | ||
}] | ||
} | ||
} | ||
}, { volume: vol }); | ||
|
||
await sd.buildAllPlatforms(); | ||
|
||
vol.readFileSync('/variables.css'); | ||
/** | ||
* :root { | ||
* --colors-red: #FF0000; | ||
* } | ||
*/ | ||
``` | ||
|
||
This also works when using extend: | ||
|
||
```js | ||
const extendedSd = await sd.extend(cfg, { volume: vol }) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.