Skip to content

Instantly share code, notes, and snippets.

@porsager
Created September 13, 2016 09:10
Show Gist options
  • Save porsager/28f02ad65eade881556be3578bd0f543 to your computer and use it in GitHub Desktop.
Save porsager/28f02ad65eade881556be3578bd0f543 to your computer and use it in GitHub Desktop.
const fs = require('fs')
, rollup = require('rollup')
, commonjs = require('rollup-plugin-commonjs')
, json = require('rollup-plugin-json')
, nodeResolve = require('rollup-plugin-node-resolve')
, stylus = require('stylus')
, nib = require('nib')
, wright = require('wright')
wright({
main: 'src/index.html',
serve: 'static',
run: 'm.redraw()',
debug: true,
js: {
watch: 'src/js/**/*.js',
compile: roll
},
css: {
watch: 'src/css/**/*.styl',
compile: style
}
})
function roll() {
return rollup.rollup({
entry: 'src/app.js',
plugins: [
json(),
commonjs(),
nodeResolve()
]
})
.then(bundle => bundle.generate({ format: 'iife' }).code)
}
function style() {
return new Promise((resolve, reject) => {
fs.readFile('src/css/style.styl', 'utf8', (err, str) => {
if (err)
return reject(err)
stylus(str)
.set('filename', 'src/css/style.styl')
.use(nib())
.import('nib')
.render((err, css) => err ? reject(err) : resolve(css))
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment