grunt postcss" not found"

时间:2015-11-13 05:00:02

标签: javascript wordpress gruntjs postcss

Grunt的新手,尝试为wordpress项目运行Gruntfile。我的根目录下有一个package.json和Gruntfile.js。我想添加grunt-postcss,但是当我按照说明操作时,我会继续"警告:任务" grunt-postcss"没找到。"我可能错误地设置了Grunt,因为无论我跑什么,我都找不到任务。这是我的Gruntfile内容:

module.exports = function(grunt) {

  grunt.initConfig({
    postcss: {
      options: {
        map: true, // inline sourcemaps
        processors: [
          require('pixrem')(), // add fallbacks for rem units
          require('autoprefixer')({browsers: 'last 2 versions'}), // add vendor prefixes
          require('cssnano')() // minify the result
        ]
      },
      dist: {
        src: 'css/*.css'
      }
    }
  });
  grunt.loadNpmTasks('grunt-postcss');

  grunt.registerTask('default', ['grunt-postcss']);
};

3 个答案:

答案 0 :(得分:1)

确保已安装grunt-postcss模块。

npm install grunt-postcss --save-dev

答案 1 :(得分:0)

我认为你应该改变

grunt.registerTask('default', ['grunt-postcss']);

grunt.registerTask('default', ['postcss']);

答案 2 :(得分:0)

  1. 确保已安装postcss。 def parse_lifts(lifts_string): """Takes a string of json and turns it into a Lifts object""" series = json.loads(lifts_string) serie_objects = [models.LiftSerie(serie["liftname"], serie["setlist"]) for serie in series] return models.Lifts(serie_objects) def parse_cardios(cardios_string): """Takes a string of json and turns it into a Cardios Object""" series = json.loads(cardios_string) serie_objects = [models.CardioSerie(serie["cardioname"], serie["duration"]) for serie in series] class LiftsField(JSONField): """Field representing a models.Lifts object""" def from_db_value(self, value, expression, connection): if value is None: return value return parse_lifts(value) def to_python(self, value): if isinstance(value, models.Lifts): return value if value is None: return value return parse_lifts(value) def get_prep_value(self, value): if not value: return value lifts_pre_json = [serie_object.pre_json() for serie_object in value.series] return json.dumps(lifts_pre_json) class CardiosField(JSONField): """Field representing a models.Cardios object""" def from_db_value(self, value, expression, connection): if value is None: return value return parse_cardios(value) def to_python(self, value): if isinstance(value, models.Cardios): return value if value is None: return value return parse_cardios(value) def get_prep_value(self, value): if value == None: return value cardios_pre_json = [serie_object.pre_json() for serie_object in value.series] return json.dumps(cardios_pre_json)

  2. 在你的shell中执行以下命令(如果你使用的话,请确保在virtualenv中):

  3. npm install grunt-postcss

    上面的命令是什么,它会更新你的PATH变量并告诉它在查找命令时也检查上面的目录。