Twitter bootstrap 使用Grunt实现无缓存引导

Twitter bootstrap 使用Grunt实现无缓存引导,twitter-bootstrap,less,gruntjs,bower,Twitter Bootstrap,Less,Gruntjs,Bower,我正在使用grunt来管理我的前端web应用程序,并想知道是否有任何方法可以加快其预编译过程。编译LESS文件(包括bootstrap)大约需要2秒的时间,对我来说,如果bootstrap.LESS不需要每次重新编译,这是有意义的。默认情况下,它可能已经被缓存了,但是有没有办法加快构建速度 Grunfile示例: grunt.initConfig({ watch: { haml: { files: '*.haml', tasks: ['haml'],

我正在使用grunt来管理我的前端web应用程序,并想知道是否有任何方法可以加快其预编译过程。编译LESS文件(包括bootstrap)大约需要2秒的时间,对我来说,如果bootstrap.LESS不需要每次重新编译,这是有意义的。默认情况下,它可能已经被缓存了,但是有没有办法加快构建速度

Grunfile示例:

grunt.initConfig({
watch: {
    haml: {
        files: '*.haml',
        tasks: ['haml'],
        options: {
            livereload: true,
        },
    },
    js: {
        files: ['*.js'],
        tasks: [],
        options: {
          livereload: true,
        }
  },
  css: {
        files: ['*.css'],
        tasks: [],
        options: {
          livereload: true,
        }
  },
  less: {
        files: ['style.less'],
        tasks: ['less'],
  },


},

您必须签出
grunt-newer
以将grunt任务配置为仅在文件更改时运行


请参见

Does
style.less
imports
boostrap.less
?如果是这样的话,恐怕就不可能进行缓存了,因为
style.less
可以重新定义/覆盖
boostrap.less
使用的变量和混合,即使引导文件根本没有修改,缓存也会失效(编译器和grunt任务都不知道这种失效是否在何时发生)。如果
style.less
boostrap.less
被编译成独立的css文件,那么只需将它们分配到不同的
watch
子任务就可以了。是的。谢谢你的解释!我想2秒钟的代价也不算太坏