Skip to content
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

Proposal for serve command? #77

Closed
tunnckoCore opened this issue Feb 2, 2018 · 9 comments
Closed

Proposal for serve command? #77

tunnckoCore opened this issue Feb 2, 2018 · 9 comments
Labels
increased scope Increases project scope, or is out of scope. wontfix

Comments

@tunnckoCore
Copy link

Heya! 🎉

First of all, yea.. it is not for apps (i think?), but it is possible to some extent. So we may include rollup-plugin-serve or *-server, and rollup-plugin-livereload.

Currently you can use watch and in another terminal to use some static serving tool, like wrapping micro(-dev) or directly us serve / budo. Budo is good enough and has livereload, but it bundles one more time unneccesary (cuz the trick is to budo dist/bundle.cjs.js --live). Also, you need to handle cleaning of dist and creating a index.html. So the scripts are something like that

{
  "scripts": {
    "index": "echo '<script src=\"./index.js\"></script>' > dist/index.html",
    "clean": "rm -rf dist",
    "predev": "yarn clean && mkdir dist && yarn index",
    "dev": "microbundle watch -f cjs --inline none",
    "server": "budo dist/index.js --live --port 5000"
  }
}
@fwilkerson
Copy link
Contributor

@olstenlarck Hi, I put together a small wrapper on microbundle that will serve your files and give you live reload. You can find the repo here https://github.com/fwilkerson/microenvi. It still needs a few features, but has served me well for prototypes and some browser environment libraries I've been working on.

@developit
Copy link
Owner

Why don't we add a link to Microenvi to the readme? I like the idea of keeping build + serve separate - in my case, I only use Microbundle for libraries, so I don't need the server bit.

@fwilkerson
Copy link
Contributor

That would be cool, I just put up a new version to go with 0.4.4.

Perhaps link to it and other things using microbundle between roadmap and license?

@developit
Copy link
Owner

Yup! That'd be great, if you want to PR :)

@cvan
Copy link

cvan commented Mar 21, 2018

first off, thanks so much for making this useful project! it reduces all the unnecessary boilerplate build-step BS I am not fond of that is so prevalent these days.

@developit: do you feel strongly about not including this in the core project? I have used @mattdesl’s https://github.com/mattdesl/budo for a lot of projects. it ships with a local-dev server, but the project is admittedly more aimed for web-app development.

in the projects I am working on that use microbundle, I also have an npm-run-all -p command to also run live-server with live-server-https. it works well!

any appetite for including that setup or @fwilkerson's microenvi out of the box?

@developit
Copy link
Owner

I'm not entirely against including a serve command. It would need to be useful for libraries though, not just web apps - maybe allow passing an alternative entry module so that a lib could microbundle serve its demos?

@andria-dev
Copy link

@developit I found this issue looking up how to do exactly that. I'm making a component to publish on npm and I'm planning on using microbundle and a microbundle serve command would definitely make that easier.

I think one of these might be nice:

Default values

Overriding the default values may become a concern at some point depending on what issues could arise. But defaulting to a tree structure like the following seems logical where demo/index.js is injected into demo/public/index.html.

.
└── demo
    ├── index.js
    └── public
        └── index.html

Pass filenames to serve

microbundle serve demo/public/index.html demo/index.js

Package.json

We could keep the information for serving in the package.json file under something like demo:

"demo": {
  "public": "demo/public/index.html",
  "entry": "demo/index.js"
}

@andria-dev
Copy link

I was looking at the directories.example for package.json and was thinking that if we defaulted to a specific folder structure one could change the folder that is used for serving via this property.

"directories": {
  "example": "path/to/my/demo-folder"
}

@benadam11
Copy link

Something like https://github.com/lukejacksonn/servor seems like it would pair really well with microbundle

@developit developit added increased scope Increases project scope, or is out of scope. wontfix and removed enhancement 🚀 help wanted 👋 labels Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
increased scope Increases project scope, or is out of scope. wontfix
Projects
None yet
Development

No branches or pull requests

6 participants