Skip to content

Instantly share code, notes, and snippets.

@attila
Created June 8, 2016 08:25
Show Gist options
  • Save attila/9baae6d7ad96fb621b5c175b45fb2e95 to your computer and use it in GitHub Desktop.
Save attila/9baae6d7ad96fb621b5c175b45fb2e95 to your computer and use it in GitHub Desktop.
Compile riot tags with Sass styles using @import
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 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) {
});
<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