Using server module with static HTML files

26 views
Skip to first unread message

jay...@gmail.com

unread,
Sep 26, 2014, 7:27:25 PM9/26/14
to mimo...@googlegroups.com
I'm very new to Mimosa so forgive me if this is a dumb question. I'm trying to figure out what seems like a fairly common use case where the server module is *only* a tool to speed development, but not a dependency of serving the deployed app.

When I use the server module, I cannot figure out how to just get *.html files copied into the output, and *.jade files compiled into *.html files in the corresponding output folder. The module seems to assume I want to serve the final application this way, but I'm using the module for live reload support and as a convenient way to serve separate projects as if they are at the server root URI (as hybrid apps need to be).

Is there a simple way to do this that I'm missing? I admit, the concept of server-side "views" is a bit alien to my experience as a front-end developer. How are these not assuming the app will be served with mimosa?

Thanks for any help. Mimosa seems awesome so far, just wish I could resolve this basic question.

dbashford

unread,
Sep 28, 2014, 4:52:59 PM9/28/14
to mimo...@googlegroups.com, jay...@gmail.com
https://github.com/dbashford/mimosa-server-template-compile

Guessing that is what you need?  If you are using .jade, that'll compile them to .html and place them right inside /public (watch.compiledDir).  It only does that for "mimosa build", as it is assumed during mimosa watch you don't need server templates compiled as they can just be served.

Let me know if that answers your question?

jay...@gmail.com

unread,
Sep 28, 2014, 5:31:30 PM9/28/14
to mimo...@googlegroups.com, jay...@gmail.com
Sorry, the group page for some reason will not let me respond to your post, so can't quote your message. I'm giving a bit more detail in response as I believe my use case may be common (or should be).

I tried the server-compile-template module (sorry if misremembering name, don't have thread in front of me). One problem is that I *would* like to have filesystem watching and copying changes to .html or .jade files as with any other resources. Having to manually rebuild on these changes while other changes are automatic is annoying. Another problem is that this also means when I am running watch -s, I am not being served these files even if I manually rebuilt them -- I'm being served the dynamic pages from the last run.

These problems are annoying enough that I'm not using the server, which means no live reload. I also found a different module -- client-jade-static -- that is more concisely doing what I need.

My use case is that I'm building hybrid mobile apps. As such, the backend is not tightly coupled, and in practice will either be a BaaS like parse.com, or no backend. Either way, all such apps require HTML pages. Having live reload is a HUGE advantage in some parts of this development, so it's frustrating not to have a good setup where I can watch and see updates but not have to manually rebuild the site on every edit to HTML/Jade/CoffeeScript. Is there some way mimosa could change to accommodate this?

For my own curiosity, having been away from the web stack for several years, is it really so ubiquitous that people use node/express as the backend that mimosa's behavior here makes sense? Even for more "traditional" web apps, for several reasons, using node for the backend is not my choice, but having it as a dev server with things like live-reload is a big plus.

Mimosa is pretty awesome still. I'm getting familiar with it. As a side point: I didn't realize that the "Config" section of the main site was the missing manual until I found it. Maybe this should be more prominent as next steps from Getting Started? Lots of great info there, just only found it after I'd spent a fair amount of time trying to make sense of the sample config file, which is unformatted so hard to see how settings are nested in places. Having plain English description of technology often hugely reduces the initial learning curve.

dbashford

unread,
Sep 28, 2014, 5:53:11 PM9/28/14
to mimo...@googlegroups.com, jay...@gmail.com
So you are in fact using jade/html as client side templates then?  So what you need is a super basic server-side html page that pulls in a few basic assets including live-reload, but otherwise you want nothing but pure .html/.jade in the UI?

There are a few of options there.

https://github.com/dbashford/mimosa-client-jade-static will compile .jade files to individual .html files on the other side.
https://github.com/emirotin/mimosa-jade-static will do the same except because its an actual "template" compiler it will bundle all the compiled jade templates into a single file.

Mimosa's behavior is agnostic to back-end.  How much you build into server templates is entirely up to you.  You can use a virtually empty server template with an essentially empty body tag.  That is what many folks do given how heavy the client is these days.

Because the server templates are capable of being as dynamic as you want them, and then capable of being compiled for deployment, if you load them up with various static things, you have quite a bit of flexibility.

dbashford

unread,
Sep 28, 2014, 5:55:16 PM9/28/14
to mimo...@googlegroups.com, jay...@gmail.com
I should point out, to further the point, we've built a half-dozen apps at my 9 to 5, all with a simple node back-end that eventually gets deployed to a non-node environment.  Mimosa is a browser development tool.  What you do on/with the server is left up to you.  There is no tie to node or really even using a server.

jay...@gmail.com

unread,
Sep 28, 2014, 9:33:34 PM9/28/14
to mimo...@googlegroups.com, jay...@gmail.com
I appreciate all that. As I've played with Mimosa and understand more, it's easier to see a workflow that works for me. My current apps don't use HTML templating since much of the GUI is canvas and SVG components that are dynamically generated within a single static page, but I find I am regularly touching the index.html file, which must be a different file than the index page served by the server module, which in turn prevents a fully DRY approach to the HTML.

At any rate, I think these are minor annoyances. The static jade modules help. Thanks for the responses.

Reply all
Reply to author
Forward
0 new messages