How to stream sass into browserSync without Gulp?

Viewed 102

I am trying to stream sass into browsersync without gulp. Here is my code


    function streamSass() {
        dev.sassTasks.forEach(task => {
            const sass = new Sass(task.src, task.dest, task.opts)
            sass.write().then(() => {
                const stream = fs.createReadStream(sass.dest.segments.absolutePath)
                stream.pipe(browserSync.stream())
            })
        })
    }

The Sass class just process and creates css file. When the function executed nothing happens on the side of the browsersync. Why is that? Assume that browsersync is running and is active when function is executed.

1 Answers

If you are not seeing anything happen then I would wager that there is something wrong with your stream as it will not throw an error and without an event handler it will silently fail.

Try adding an error event handler:

stream.on('error', err => console.log(err));
Related