Sunday, 9 April 2017

Pug (Jade) templates: automatically update references to scripts and stylesheets with fingerprinted version in CDN

I am working on a Koa.js application with Pug as the template engine. I would like to create an automated process so that the production templates have the URLs of the JavaScript and CSS files updated with fingerprinted names and a base URL to a certain CDN provider. I have found a plugin for gulp (gulp-jade-usemin) to replace the references to non-optimized scripts or stylesheets, but after that I would like to update the optimized references with the fingerprinted version in a CDN provider.

I have set up in the past a similar process for an Express application with Swig as the template engine using a bunch of grunt plugins (grunt-contrib-copy, grunt-hashres, grunt-processhtml, grunt-cdn), but I cannot find a way to set up something similar with Pug, mainly because the templates are not natively HTML.

I am willing to use grunt, gulp or any other automation tool.



via Carlos Rodriguez

No comments:

Post a Comment