Gulp sass输出错误

时间:2017-09-22 15:40:20

标签: sass gulp gulp-sass

鉴于此gulpfile.js:

var gulp = require("gulp"),
    sass = require("gulp-sass"),
    sourcemaps = require("gulp-sourcemaps"),
    autoprefixer = require("gulp-autoprefixer"),
    input = "./sass/*.scss",
    output = "./assets/style.css";

gulp.task("sass", function() {
    return gulp
        .src(sassInput)
        .pipe(sourcemaps.init())
        .pipe(sass(sassOptions).on("error", sass.logError))
        .pipe(sourcemaps.write())
        .pipe(autoprefixer())
        .pipe(gulp.dest(output))
        .resume();
});
gulp.task("watch", function() {
    return (gulp
            //watch input folder for change and then run 'sass' task
            .watch(input, ["sass"])
            .on("change", function(e) {
                console.log(
                    "file" + e.path + " was " + e.type + ", running tasks..."
                );
            }) );
});

我收到以下错误 -

Error: EEXIST: file already exists, mkdir './assets/style.css'

从我在网络上发现的情况来看,似乎gulp将输出文件夹的'style.css'部分视为目录本身,或类似的东西,但我无法弄明白。

1 个答案:

答案 0 :(得分:0)

有一个专门为此目的而构建的gulp-rename工具。这是我添加的片段,以便在添加npm包后使其正常工作。

var gulp = require("gulp");
     .
     .
     .
var rename = require("gulp-rename")

input = "./sass/*.scss",
output = "./assets/";

gulp.task("sass", function() {
    return gulp
        .src(sassInput)
             .
             .
             .
        .pipe(rename("styles.css.liquid"))
        .resume();
});