2015-07-11 117 views
1

我將* .less文件編譯成* .css文件,使用node,js和grunt,然後我需要改變屬性的順序並創建最終的css文件,爲此我試圖使用grunt-csscombgrunt csscomb不起作用

Gruntfile.js

module.exports = function (grunt) { 

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

    less: { 
     development: { 
      options: { 
       compress: false 
      }, 
      files: { 
       "css/unsorted_style.css": "less/style.less" 
      } 
     } 
    }, 

    csscomb: { 
     foo: { 
      files: { 
       'css/style.css': ['css/unsorted_style.css'] 
      } 
     } 
    }, 

    watch: { 
     less: { 
      files: ['less/*.less'], 
      tasks: ['less'], 
      options: { 
       spawn: false 
      } 
     }, 

     css { 
      files: ['css/unsorted_style.css'], 
      tasks: ['css', 'csscomb'], 
      options: { 
       spawn: false 
      } 
     } 

    } 
}); 

grunt.loadNpmTasks('grunt-contrib-less'); 
grunt.loadNpmTasks('grunt-csscomb'); 
grunt.loadNpmTasks('grunt-contrib-watch'); 

grunt.registerTask('default', ['less', 'csscomb', 'watch']); 

}; 

,但我得到一個錯誤enter image description here

有什麼不對?如何解決它?

回答

0

您在css

module.exports = function (grunt) { 

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

    less: { 
     development: { 
      options: { 
       compress: false 
      }, 
      files: { 
       "css/unsorted_style.css": "less/style.less" 
      } 
     } 
    }, 

    csscomb: { 
     foo: { 
      files: { 
       'css/style.css': ['css/unsorted_style.css'] 
      } 
     } 
    }, 

    watch: { 
     less: { 
      files: ['less/*.less'], 
      tasks: ['less'], 
      options: { 
       spawn: false 
      } 
     }, 

     css: { 
      files: ['css/unsorted_style.css'], 
      tasks: ['css', 'csscomb'], 
      options: { 
       spawn: false 
      } 
     } 

    } 
}); 

grunt.loadNpmTasks('grunt-contrib-less'); 
grunt.loadNpmTasks('grunt-csscomb'); 
grunt.loadNpmTasks('grunt-contrib-watch'); 

grunt.registerTask('default', ['less', 'csscomb', 'watch']); 

}; 
錯過了 :