如何缩小DocPad中的HTML,CSS和JavaScript文件? [英] How can I minify HTML, CSS and JavaScript files in DocPad?

查看:119
本文介绍了如何缩小DocPad中的HTML,CSS和JavaScript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在点击docpad generate时最小化HTML,CSS和JavaScript文件,该怎么办?

I would like to minify HTML, CSS and JavaScript files when I hit docpad generate, how can I do that?

推荐答案

有几种方法可以解决此问题.最突出和最直接的方法是修改您的 docpad配置文件以触发诸如通过此处是要说明的要点.

There are a few ways you can go about this. The most prominent and most immediate way is to modify your docpad configuration file to trigger an external tool like grunt to minify your assets via the grunt minify task. Here is a gist that showcases this.

或者,还有 Cloudflare ,这是一个了不起的网站DNS服务器,它还充当网站内容的CDN,并在部署后自动最小化您的资产. 在此处了解更多信息.

Alternatively, there is also Cloudflare which is an amazing website DNS server that also acts as a CDN for your website's content, and minifies your assets automatically post-deployment. Read more here.

此外,虽然它与最小化无关,但是您也可以将脚本与 Browserify 连接起来使用此要点.通过 grunt concat,Grunt还具有更直接的连接方式任务.

Also, while it isn't minify related, you can also concatenate your scripts with Browserify using this gist. Grunt also has a more straightfoward way of concatenating as well via the grunt concat task.

最终,也许插件会自动执行此操作,但是考虑到反复出现的变幻无常,可能需要一段时间.

Eventually, perhaps plugins will do this automatically, but considering the fickleness with concatination it could be a while.

这篇关于如何缩小DocPad中的HTML,CSS和JavaScript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆