Skip to content

Instantly share code, notes, and snippets.

@joonazan
Created May 14, 2018 20:56
Show Gist options
  • Save joonazan/fe71915d730550cf31504abce63b5e1d to your computer and use it in GitHub Desktop.
Save joonazan/fe71915d730550cf31504abce63b5e1d to your computer and use it in GitHub Desktop.
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