Dasix / grits

An opinionated Dust.js Renderer with Markdown and Front-Matter features added.
Other
0 stars 1 forks source link

Add "Post Processing" operations and options #86

Open vmadman opened 7 years ago

vmadman commented 7 years ago

Right now, virtually everything that Grit.js does happens before or during the rendering process.

However, there are a number of things that could/should happen after rendering and it would be extremely useful if Grits could do some of them.

Most post processing operations could be included in various Grits plugins, but some of the more fundamental operations could be embedded directly into Grits core.

Configuration:

Of course, post processing operations could be configured in the usual ways, like through the Grits config file, and via CLI options (see also #12).

I was also thinking about a novel way of allowing certain types of operations to be configured by using "placeholder" files that grits will recognize as being post-processing configs and then execute them at the end of rendering ops (when applicable).

As an example, consider JS concatenation and minification.

The user would create a new config file (YAML, JSON, or TOML) such as...

/src/content/js/main.js_.yaml

post-processors:
  - concat
  - minify
include:
  - lib/jquery.js
  - custom/**/*.js
options:
   obfuscate: false
priority: 1

.. and grits would then know to execute the post processor whenever the include pattern(s) match a file that Grits renders or copies. It also knows that the output for the post processing op should be placed at /dist/js/main.js.

The naming syntax for the placeholder files still need more consideration, since I am not thrilled about how that js_.yaml example, above, looks, but I think the concept is reasonably sound.

Post-Processing Operation Examples:

vmadman commented 7 years ago

This issue is, more or less, a duplicate of #46. However, since it's not an exact duplicate, I am going to leave them both open, for now.