【问题标题】:Unable to log error with postcss reporter and postcss bem linter in Gruntfile无法在 Gruntfile 中使用 postcss 报告器和 postcss bem linter 记录错误
【发布时间】:2015-09-27 23:17:27
【问题描述】:

我在我的 gruntfile.js 中使用 grunt-postcss 并且一切正常,除了 postcss-bem-linter 如果不遵循 BEM 规则,它应该在控制台中记录警告。这里是 gruntfile.js 中的一个 sn-p 配置:

var preprocessorsAfterSprites = [
    require('postcss-bem-linter')(function (a) {
        console.log(a);
    }), // this just doesn't want to work right now
    require('postcss-reporter')
];

function getPostCssPreprocessors(name) {
    return preprocessorsAfterSprites;
}

grunt.initConfig({
    postcss: {
        options: {
            map: { inline: false }
        },
        golden: {
            src: '<%= dirs.pcss %>/golden/main.scss',
            dest: '<%= dirs.css %>/golden.css',
            options: {
                processors: getPostCssPreprocessors('golden')
            }
        }
    }
});

当我尝试输入 grunt postcss:golden 时,控制台日志没有任何输出。任何想法为什么?

【问题讨论】:

    标签: javascript gruntjs gruntfile


    【解决方案1】:

    postcss-bem-linter 不接受回调 (https://github.com/postcss/postcss-bem-linter)。所以我不知道你为什么认为require('postcss-bem-linter')(function (a) { console.log(a); }) 应该可以工作。

    【讨论】:

      猜你喜欢
      • 2021-05-20
      • 2017-07-29
      • 2016-04-10
      • 2021-03-03
      • 2017-02-26
      • 2021-06-09
      • 2022-10-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多