How can I minify HTML, CSS and JavaScript files in DocPad?

后端 未结 2 1261
鱼传尺愫
鱼传尺愫 2021-02-04 15:27

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

相关标签:
2条回答
  • 2021-02-04 16:11
    • Use gruntjs for JS files. (Grunt will hook up into docpad generate)
    • Use grunt-contrib-mincss for css files.
    • Use grunt-contrib-htmlmin for html files.
    • Use grunt-compress for compressing all files.

    For list of all grunt plugins look here: https://github.com/gruntjs

    0 讨论(0)
  • 2021-02-04 16:14

    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.

    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.

    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.

    0 讨论(0)
提交回复
热议问题