Created
May 14, 2018 20:56
-
-
Save joonazan/fe71915d730550cf31504abce63b5e1d to your computer and use it in GitHub Desktop.
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
var listSelectors = require('list-selectors'); | |
var fs = require('fs') | |
module.exports = function(elmsource) { | |
function makeLine(prefixedName) { | |
const name = prefixedName.substr(1) | |
return `${name} = "${name}"` | |
} | |
const source = 'src/style.scss' | |
this.addDependency(source) | |
listSelectors(source, {include: ['ids', 'classes']}, | |
function(res){ | |
const assignments = | |
res.classes.concat(res.ids).map(makeLine).join('\n') | |
fs.writeFile( | |
'src/Sty.elm', | |
'module Sty exposing (..)\n' + assignments | |
) | |
}) | |
return elmsource | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment