gpt4 book ai didi

string - 在 Gulp 中是否可以使用字符串而不是源文件开头?

转载 作者:行者123 更新时间:2023-12-01 05:04:08 27 4
gpt4 key购买 nike

通常,当我使用 Gulp 时,我会从以下内容开始:

gulp.src('some/file.txt).pipe( ... ) // etc

我也可以使用字符串而不是文件吗?例如:
gulp.str('some text').pipe( .... ) // etc

我正在处理的用例是我正在创建一个 SCSS 字符串临时并希望将其通过管道传输到 libsass。但我不想创建一个临时文件,而是使用原始字符串。例子:
var myString = 'html { color: red; }';
gulp.str(myString).pipe(sass()) // etc

这可能吗?

最佳答案

你可以尝试这样的事情:

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'));
});

关于string - 在 Gulp 中是否可以使用字符串而不是源文件开头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30578140/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com