-
-
Save kcjpop/f575d8b11f8e4ff72430aad22d1cd795 to your computer and use it in GitHub Desktop.
This file contains 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 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