【问题标题】:Error when compiling Less in Gulp: `File not found with singular glob`在 Gulp 中编译 Less 时出错:`File not found with single glob`
【发布时间】:2020-09-09 03:19:09
【问题描述】:

我正在开发一个有一些预先设置的 Gulp 命令的旧网站。

我想将一些 .less 文件编译成 .css。现有的脚本是这样的:

gulp.task('less', function(){
  return gulp.src('./src/css/less/app.less')
  .pipe(less({
    paths: [ path.join(__dirname, 'less', 'includes') ]
  }))
  .pipe(gulp.dest('./src/css/'))
});

但是,当我运行它时,我得到一个错误:

Error: File not found with singular glob: /src/css/less/app.less (if this was purposeful, use `allowEmpty` option)

我检查了所有路径、所有@import 和目录,它们都没有问题。

我正在使用 Gulp Local:4.0.0,CLI:2.3.0。

有人知道这可能是什么原因吗?

【问题讨论】:

  • 该路径应该与您的 gulpfile.js 相关。是吗?
  • @Mark Doh!不是!谢谢!

标签: npm gulp less


【解决方案1】:

也许稍后,但 Gulp 4 有一种用于编写任务的新语法。 此外,您必须修复错误的源文件路径:

    // gulpfile.js
    const SRC = 'src';
    const DIST = 'src';

    function lessTask(cb) {
        return src(SRC + '/less/app.less')
            .pipe(less())
            .pipe(dest(DIST + '/style.css'));
    }

    exports.default = series(lessTask);
    # On terminal:
    gulp

【讨论】:

    猜你喜欢
    • 2016-08-25
    • 2012-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-22
    相关资源
    最近更新 更多