Normally when I use Gulp I start with:
gulp.src('some/file.txt).pipe( ... ) // etc
Can I also use a string instead of a file? For example:
gulp.str('some text').pipe( .... ) // etc
The use case I'm working on is that I'm creating a SCSS string ad-hoc and want to pipe it to the libsass. But I don't want to have create a temporary file but use a raw string instead. Example:
var myString = 'html { color: red; }';
gulp.str(myString).pipe(sass()) // etc
Is this possible?
You may try something like this:
var file = require('gulp-file');
gulp.task('build', function () {
var str = 'Some string value that you want to pipe';
return file('tmp.js', str, { src: true }) // The file name can be anything
... // <- Piping contents of str here
.pipe(gulp.dest('xxx'));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With