Created
May 26, 2015 02:59
-
-
Save geelen/1667acc69a5e9ea65438 to your computer and use it in GitHub Desktop.
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
/* equivalent to postcss-local-scope. INPUT: */ | |
.outer { | |
color: papayawhip; | |
box-shadow: 0 0 10px; | |
} | |
/* OUTPUT: */ | |
@export .outer ".outer-abcs12r3adudas"; | |
.outer-abcs12r3adudas { | |
color: papayawhip; | |
box-shadow: 0 0 10px; | |
} |
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
/* equivalent to css-loader modules now. INPUT: */ | |
/* traits.css */ | |
.trait-colors--papaya { | |
color: papayawhip; | |
} | |
/* component.css */ | |
.outer { | |
extends: .trait-colors--papaya from "./traits.css"; | |
box-shadow: 0 0 10px; | |
} | |
/* INTERMEDIATE (both files compiled separately): */ | |
/* traits.css */ | |
@export .trait-colors--papaya ".trait-colors--papaya-zxcv12r3adudas"; | |
.trait-colors--papaya-zxcv12r3adudas { | |
color: papayawhip; | |
} | |
/* component.css */ | |
@import "./traits.css" .trait-colors--papaya:".tmp-class-bvc4543shf"; | |
@export .outer ".outer-abcs12r3adudas .tmp-class-bvc4543shf"; | |
.outer-abcs12r3adudas { | |
box-shadow: 0 0 10px; | |
} | |
/* OUTPUT: */ | |
/* traits.css unchanged */ | |
/* component.css has imports resolved */ | |
@export .outer ".outer-abcs12r3adudas .trait-colors--papaya-zxcv12r3adudas"; | |
.outer-abcs12r3adudas { | |
box-shadow: 0 0 10px; | |
} |
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
/* INPUT (probably output of your POSTCSS plugin) */ | |
/* vars.css */ | |
@export --papaya "--papaya-gfhjs43672fghfds"; | |
:root { | |
--papaya-gfhjs43672fghfds: #ffefd5; | |
} | |
/* component.css */ | |
@import "./vars.css" --papaya:"--tmp-var-tyuy3246ads"; | |
.outer { | |
color: var(--tmp-var-tyuy3246ads); | |
box-shadow: 0 0 10px; | |
} | |
/* OUTER */ | |
/* vars.css unchanged */ | |
/* component.css has imports resolved */ | |
@export .outer ".outer-abcs12r3adudas"; | |
.outer-abcs12r3adudas { | |
color: var(--papaya-gfhjs43672fghfds); | |
box-shadow: 0 0 10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Syntax for
@import
and@export
totally up for grabs, but hopefully this shows how making a low-level import/export syntax supports lots of use-cases, just like a good module format should!For the record, here's the current grammar I came up with: