-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: write all router paths to disk #60
Comments
How might this look with regard to budo? I'm trying to envision how a small GH pages site/demo like this could use Can you give example of other routes that might be worth persisting? |
Ah yes, I should've been a bit more clear in that respect. What you're outlining is exactly the use case for this.
A simplified config could look like: ./router.js const toServer = require('wayfarer-to-server')
const html = require('simple-html-index')
const wayfarer = require('wayfarer')
const watchify = require('watchify')
const uglify = require('uglifyify')
const router = toServer(wayfarer())
module.exports = router
router.on('/', {
get: (req, res) => html().pipe(res))
})
const b = watchify('./index.js')
.plugin(uglify())
router.on('/bundle.js', {
get: (req, res) => b.bundle().pipe(res)
}) ./to-fs.js const toFs = require('wayfarer-to-fs')
const router = require('./router')
const path = require('path')
const directory = path.join(__dirname, 'dist')
const overrides = { '/': '/index.html' }
toFs(router, directory, overrides, (err) => {
if (err) throw err
}) |
This looks good; the only thing is that typically you end up with different dev and prod configurations; like using Also, I guess how would it manifest itself on the end-user? How would these two lines be replaced? As it states in uglifyify readme, you generally still want to run uglifyjs on the final bundle. |
"scripts": {
"start": "budo index.js:bundle.js --live -- -t babelify | garnish",
"build": "budo --write index.js:bundle.js -t babelify -t uglifyify -o ./dist"
} Does this answer your question? edit: yeah, this would mean that direct unix pipes don't work, but luckily practically all bundle actions are available as browserify transforms. edit: oh, you're right about the "scripts": {
"start": "budo index.js:bundle.js --live -- -t babelify | garnish",
"build": "budo --write index.js:bundle.js -t babelify -t uglifyify -o ./dist && npm run optimize",
"optimize": "uglify -s dist/bundle.js | sponge | dist/bundle.js
} I admit it's not ideal, but I think it's somewhat of a corner case. Alternatively we could use a flag to pipe some of the files through to stdout (which would mean extending $ budo --write --raw index.js -t babelify -t uglifyify -o ./dist | uglify > dist/bundle.js but I think this approach creates more problems than it solves. |
I think browserify options could still be passed after the full stop, and maybe the flag could look something like this: budo index.js:bundle.js --write=./static/ -- -t babelify -t uglifyify Could be named I actually think this feature would be pretty nice. |
+1! |
More thoughts:
The way I've solved this for my projects is to use quick-build which installs latest Anyways, this is still unresolved since I'm open to discussing it further, but hopefully we can find a way that isn't too complex/painful. 😄 |
Pardon the necro but I just wanted to chime in to point out that it seems the hold up here is around optimization for production; I'd like to suggest that there's a need for output/export/write in a prototyping tool -- to share your prototype. Yes, you can just use Currently, my build script looks something like Generating a
|
Can't wait for the feature, in the meantime https://github.com/dy/budo |
FWIW I implemented this in canvas-sketch and it introduces a number of new considerations:
This feature might be a bit awkward if implemented in budo currently, as budo wasn't really designed with it in mind, and it really increases the opinions and surface area of budo. I'm open to other creative solutions, though. PS: Forking budo is actually a fine solution, or even creating a new npm module on top of budo. Budo is pretty stable, and probably won't be receiving many more changes as I'd rather keep it bare-bones. The |
It might be cool if
budo
's routes were able to be persisted to disk. This would allow users to prototype using a live-reloading environment, and once they're happy with the results store the output to disk and deploy it to GH-pages.Currently the following modules are available to do this:
wayfarer-to-server
paths to diskUsage looks like this:
What do you think of adding such functionality to
budo
?The text was updated successfully, but these errors were encountered: