Created
June 8, 2016 08:25
-
-
Save attila/9baae6d7ad96fb621b5c175b45fb2e95 to your computer and use it in GitHub Desktop.
Compile riot tags with Sass styles using @import
This file contains hidden or 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
$color: red; |
This file contains hidden or 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
const compiler = require('riot-compiler'); | |
const fs = require('fs'); | |
const tagFile = './example.tag'; | |
const outFile = './example.js'; | |
const options = {}; | |
fs.readFile(tagFile, (err, source) => { | |
if (err) { | |
throw err; | |
} | |
const js = compiler.compile(source.toString(), options, tagFile); | |
fs.writeFile(outFile, js); | |
}); |
This file contains hidden or 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 is the compiled output | |
riot.tag2('example', '<p>This is an example tag.</p>', 'example p,[riot-tag="example"] p,[data-is="example"] p{ color: red; }', '', function(opts) { | |
}); |
This file contains hidden or 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
<example> | |
<p>This is an example tag.</p> | |
<style type="text/scss" scoped> | |
@import 'variables'; | |
p { | |
color: $color; | |
} | |
</style> | |
</example> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment