How to concatenate and minify multiple CSS and JavaScript files with Grunt.js (0.3.x)

前端 未结 5 420
半阙折子戏
半阙折子戏 2020-11-28 18:18

Note: This question is only relevant for Grunt 0.3.x and has been left for reference. For help with the latest Grunt 1.x release please see my comment below this questio

5条回答
  •  迷失自我
    2020-11-28 18:50

    I want to mention here a very, VERY, interesting technique that is being used in huge projects like jQuery and Modernizr for concatenate things.

    Both of this projects are entirely developed with requirejs modules (you can see that in their github repos) and then they use the requirejs optimizer as a very smart concatenator. The interesting thing is that, as you can see, nor jQuery neither Modernizr needs on requirejs to work, and this happen because they erase the requirejs syntatic ritual in order to get rid of requirejs in their code. So they end up with a standalone library that was developed with requirejs modules! Thanks to this they are able to perform cutsom builds of their libraries, among other advantages.

    For all those interested in concatenation with the requirejs optimizer, check out this post

    Also there is a small tool that abstracts all the boilerplate of the process: AlbanilJS

提交回复
热议问题