dlmanning / gulp-sass

SASS plugin for gulp
MIT License
1.57k stars 381 forks source link

Compiles empty files if the source is in base directory #738

Closed SteinTheRuler closed 5 years ago

SteinTheRuler commented 5 years ago

If the source file is in a subdirectory of base it compiles as expected, but when the file is in the base directory ("./") the compiled file is empty.

Files.zip

const { src, dest, series, parallel, watch, del } = require("gulp");
const changed = require("gulp-changed");
const fiber = require("fibers");
const print = require("gulp-print").default;
const rename = require("gulp-rename");
const buildPath = dest => "./_Build/" + dest;

function styleChanged () {
    const sass = require("gulp-sass");
    const destPath = buildPath("STYLE");
    const theTask = outStyle => {
        return src("./STYLE/**/*.scss")
            .pipe(changed(destPath))
            .pipe(sass({fiber: fiber, outputStyle: outStyle}).on("error", sass.logError))
            .pipe(rename(function (path) {
                var basename = path.basename;

                if (path.dirname !== ".") {
                    basename = path.dirname + "." + basename;
                }

                path.basename = basename;
                path.dirname = "./";
            }))
            .pipe(dest(destPath));
        };

    return theTask("expanded");
}

function watchFiles () {
    watch("./STYLE/**/*.scss", styleChanged);
}

exports.default = watchFiles;
exports.styleChanged = styleChanged;