0

我有一个简单的文件,内容很少,但编译时间从 10 到 27 秒不等。关于为什么的任何想法?是我的机器还是我缺少的咕噜声设置?我需要清除某种缓存吗?

Gruntfile.js 内容

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    less: {
      development: {
        options: {
          paths: ["../css"]
        },
        files: {
          "../css/main.css": "../less/main.less",
        }
      },
      bootstrapBuild : {
        options : {
          paths: ['../css']
        },
        files : {
          "../css/bootstrap.css": "../less/bootstrap.less",          
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      markup: {
            files: ['../*.php', '../inc/*.php'],
            options: {
                livereload: true,
            }
      },
      scripts: {
        files: ['../js/*.js'],
        tasks: [],
        options: {
          livereload: true,
          spawn: false
        },
      }, 
      mainCSS: {
        options: {
          livereload: false,
          spawn: false
        },
        files: ['../less/main.less', '../less/responsive/*.less', "../less/common.less"],
        tasks: ['less:development']
      }, 
      bootstrapBuild : {
        options: {
          livereload: false,
          spawn: false
        },
        files: ['../less/*.less', '!../less/main.less', "!../less/common.less"],
        tasks: ['less:bootstrapBuild'],
        spawn: false
      }, 
      css: {
          files: ['../css/*.css'],
          tasks: []
      }   
    }
  });

  // Less
  grunt.loadNpmTasks('grunt-contrib-less');

  // Watch
  grunt.loadNpmTasks('grunt-contrib-watch');

};

Package.json 内容

{
  "name": "Project-Markup",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-nodeunit": "^0.4.1",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-contrib-less": "^0.11.4"
  }
}

main.less 内容

body{
    background: red;
}


/* End of Main */
4

2 回答 2

0

这个 grunt-timer 模块可以帮助你追踪它:

https://github.com/leecrossley/grunt-timer/blob/master/README.md

如果您发现某个特定任务需要一段时间,您可以尝试 grunt-changed 仅在每个任务发生更改时才构建它:

https://www.npmjs.com/package/grunt-changed

于 2015-07-16T02:14:55.150 回答
0

也许不是编译过程花了这么长时间,而是模块的加载;这是大多数时候的原因。

看看这篇文章:即使它不能解决您的问题,它也可能会提示您需要这么长时间。

于 2015-08-06T11:51:50.390 回答