I would like to have all javascript, css and images that are sent to the browser to be concatenated, minified and have a md5 cache busting filename. I’ve been able to achieve this with packages like connect-assets and others.
However I have not been able to add the md5’ed image filename into the css before it is processed.
I am using Less css templates.
Any pointers to packages that could help me would be great.
eg
image.png is converted to image-455454545.png
css references background-image: url(image.png) -> should change to image-455454545.png
As far as I know, Less doesn’t have the ability to utilize user-defined functions. Stylus, however, does. So if you’re willing to hop onto an alternate CSS preprocessor, then there is great fun to be had! (Stylus is really very simliar to Less, and it shouldn’t take much to switch to it. Plus
connect-assetsalready supports Stylus, so it should plug into your environment easily.)server.js
styles.styl
Which will compile into:
styles.css