bmatcuk / brunch-static

Transform static files using brunch.
MIT License
10 stars 2 forks source link

summary file generation #1

Open jahbini opened 8 years ago

jahbini commented 8 years ago

Please look at jahbini/brunch-static-archive -- I had need of a client-side summary of all the static files generated by brunch-static. The major change (in addition to a couple of other archives to process teacup templates) is that all head-matters are collected into a singe Backbone Collection and then dumped when Brunch calls onCompile. The JSON is dumped into the site folder and a watchful brunch wakes up and includes it into the application's javascript.

I would like to add this to your arsenal of good fun. What is your suggestion? Pull request? Separately maintained repositories?

bmatcuk commented 8 years ago

hmm, well, I think your project solves a rather specific problem, so it doesn't make sense to include it into the purposefully generic brunch-static project. However, maybe there is some functionality I could add to brunch-static that would allow you to write your project as a plugin so it could work with brunch-static instead of diverging the codebase? What functionality would you need? Some kind of hook into compile()? It's hard to tell what changes you made since you didn't use github's "fork" functionality...

Actually, it looks like you're most interested in the front matter, which brunch-static knows nothing about. So, I assume you're also using html-brunch-static. It might make more sense to add something there. It looks like you just need to know the filename and the front matter for each compiled file, and then a hook into onCompile()?

jahbini commented 8 years ago

I tried exactly that: just working on html-brunch-static, but only brunch-static is the direct plug-in for brunch. Hence only brunch-static is eligible for onCompile.

bmatcuk commented 8 years ago

Ya, I suppose brunch-static would need to forward that on to html-brunch-static for it to work.

facboy commented 8 years ago

it seems that brunch-static does not define onCompile itself for files that it creates, so hooks in the main brunch-config do not see the files that brunch-static has created.

though admittedly i'm not entirely sure how the interaction between plugins and the onCompile hook is supposed to work. it seems that brunch-static returns empty data in the callback so brunch doesn't know what it has done.

bmatcuk commented 8 years ago

Well, the problem is that brunch is not meant to handle plugins like this. Plugins are supposed to return javascript or css that get appended to the combined javascript or css file, respectively. brunch-static, on the other hand, dumps its output to a file, so it returns nothing. There's no way in brunch to return a list of filenames that have been built by the plugin.

There's been some talk about adding features for this, but, so far, it hasn't made it into brunch as far as I know.

facboy commented 8 years ago

maybe the new staticCompile features in brunch 2.8.0? released 4 days ago :).

bmatcuk commented 8 years ago

Ah, so they did accept that pull request... last I saw, they were rejecting it. Ok, I'll need to cut a new version of brunch-static =)