【问题标题】:Grunt default task only runs first task in the listGrunt 默认任务只运行列表中的第一个任务
【发布时间】:2014-06-20 21:41:56
【问题描述】:

我刚刚开始使用 grunt,只是尝试完成一些基本任务。 这是我的 Gruntfile:

module.exports = function(grunt) {
  grunt.initConfig({
    compass: {
      dist: {
        options: {
          config: 'config.rb',
          watch: true
        }
      }
    },
    livecopy: {
      your_target: {
        options: {
          source: "C:/Websites/xxx/styles/screen.css",
          target: "W:/Websites/xxx/styles/screen.css"
        },
      },
    },
    watch: {
      assets: {
        files: ['**//*.css', '**/*.js'],
        options: {
          livereload: true,
        },
      },
    },

  });
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-livecopy');
  grunt.task.registerTask('default', ['compass','livecopy','watch']);
};

我可以单独运行这些任务中的每一个,而不会出现任何问题。当我运行 grunt 默认任务时,只有默认任务列表中的第一个任务运行。它们的顺序无关紧要,只有第一个运行。

我错过了什么?

【问题讨论】:

    标签: gruntjs


    【解决方案1】:

    当您使用 watch 选项运行 Compass 时,它会运行 compass watch,这是一个阻塞任务。来自grunt-contrib-compass docs

    观看

    类型:布尔值

    运行 compass watch 而不是 compass 编译。这将使用指南针 原生 watch 命令监听 Sass 文件的变化并重新编译 你的 CSS 上的变化。虽然比运行 compass compile 快得多 每次你想编译你的 Sass 时,Compass 就变成了一个阻塞 任务。这意味着如果您想将它与 另一个阻塞任务,例如监视,您将需要在 与 grunt-concurrent 等并行任务结合使用。

    【讨论】:

      猜你喜欢
      • 2015-12-24
      • 2016-10-02
      • 2015-03-23
      • 1970-01-01
      • 1970-01-01
      • 2013-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多