statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.64k stars 235 forks source link

JavaScript best practices #922

Closed makma closed 3 years ago

makma commented 3 years ago

As a web developer, I'd like to use JavaScript heavily in my site powered by Statiq.

How to integrate into the build/framework pipeline:

st3phhays commented 3 years ago

i am curious about this too as I am looking to implement gulp.js to take care of a lot of the minification/bundling. There are a lot of great plugins I use to really shrink down the size of things and get rid of unneeded css, as well as manage some of the external libraries (like bootstrap). I am unsure though of where to add this into the build pipeline to work with Statiq.

daveaglick commented 3 years ago

My thinking at the moment is to add support to Statiq Web for running CLI apps out of process, with some default commands for common bundlers like webpack, gulp, etc. but extensibility to add your own. Statiq itself already has a pretty powerful StartProcess module, so hopefully this is mostly rigging that up to a default pipeline in Statiq Web, providing some conventions around settings that drive it, and figuring out a few good default scenarios.

I've still got some open questions I'll need to experiment with like which files the bundler should be run on (input or post-output), whether it should stay resident in the background or get run at the end of every generation, etc. I'll need to experiment a bit to figure that part out.

TL;DR: this is probably the next thing I'll work on, so expect to see some movement here soon.

daveaglick commented 3 years ago

I think I've got a decent design for this:

daveaglick commented 3 years ago

A couple adjustments:

Work has started and is progressing quickly as anticipated. The first step was splitting out process launching from the StartProcess module so it could be used outside the module for launching tasks.

daveaglick commented 3 years ago

I ended up going with a more specific "processes" term for this - it turns out that tasks vs. .NET Task was breaking my brain, and the more I thought about it, the more I don't really want this to be other than external processes anyway (running arbitrary code is what modules are for).

Anyway, it's alive!

image

Still have some polish to do, will hopefully ship a first version with support for custom-defined processes this weekend and then start looking at defining some in-the-box ones (kind of like Hugo Pipes).

daveaglick commented 3 years ago

Support for "processes" has shipped, I'll try to get the concept documented in the next day or two. I decided to go ahead and ship the underlying feature before adding any specific process support for stuff like gulp, webpack, etc. I'll open new issues for those. In the meantime, you should be able to integrate whatever preferred tooling you use if you know the command line for it.

There are four bootstrapper extensions that light this up depending on when you want the process to run: