Created
September 13, 2016 15:24
-
-
Save cmnstmntmn/d40b34fdfc6b5c2bd669177cce43c100 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
{ | |
"name": "www", | |
"version": "1.0.0", | |
"scripts": { | |
"dev": "node tasks/wright.dev.js", | |
"prod": "node tasks/wright.prod.js" | |
}, | |
"dependencies": { | |
"rollup": "^0.35.9", | |
"wright": "github:porsager/wright" | |
}, | |
"devDependencies": { | |
"nib": "^1.1.2", | |
"postcss": "^5.2.0", | |
"rollup-plugin-commonjs": "^4.1.0", | |
"rollup-plugin-json": "^2.0.2", | |
"rollup-plugin-node-resolve": "^2.0.0", | |
"stylus": "^0.54.5" | |
} | |
} |
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
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: 'http://my-www.dev', | |
serve: 'public', | |
fps: true, | |
debug: true, | |
run: 'window.reload()', | |
js: { | |
jail: true, | |
watch: 'resources/js/**/*.js', | |
compile: roll | |
}, | |
css: { | |
watch: 'resources/css/**/*.styl', | |
compile: style | |
}, | |
watch: '**/*.php' | |
}) | |
function roll() { | |
return rollup.rollup({ | |
entry: 'resources/js/app.js' | |
}).then(bundle => bundle.generate({ format: 'iife' }).code) | |
} | |
function style() { | |
return new Promise((resolve, reject) => { | |
fs.readFile('resources/css/app.styl', 'utf8', (err, str) => { | |
if (err) | |
return reject(err) | |
stylus(str) | |
.set('filename', 'resources/css/app.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