gulp - Gulp-replace 不工作最新版本
问题描述
// Create a scss theme file
gulp.task('theme-scss', function() {
return gulp.src(['./retailer-theme.json']).on('error', gutil.log)
.pipe(replace('/.*/m', 'hello')).on('error', gutil.log)
//.pipe(jsonSass({prefix: '$theme: '})).on('error', gutil.log)
/*.pipe(rename({
dirname: './',
basename: 'retailer',
suffix: '-theme',
extname: '.scss'
})).on('error', gutil.log)*/
.pipe(gulp.dest(APP_DIR + '/scss/variables/')).on('error', gutil.log)
})
尝试用单词 hello 替换文件中的所有内容。enter code here
Retailer-theme.json 中的文本是文本
.pipe(replace('text', 'hello')).on('error', gutil.log)
上面的行按预期工作
解决方案
实际上,如果您只是从原始正则表达式中删除了引号
.pipe(replace('/.*/m', 'hello')).on('error', gutil.log)
至
.pipe(replace(/.*/m, 'hello')).on('error', gutil.log)
我敢打赌它有效。有了引号,它就找不到匹配项了。
推荐阅读
- uitableview - 插入行后有没有办法显示键盘?
- python - Shouldn't my try/except block have caught this AttributeError?
- android - 如何使用 RecyclerView 和 Android Studio 中的按钮将项目添加到列表并因此删除它们?
- java - 将 .txt 文件中的所有单词添加到自定义对象的 ArrayList
- typescript - 并行运行一组 TaskEithers,但如果 1 个或多个任务失败则继续
- c# - 需要帮助手动添加到字典
- testing - 多个 if 语句的圈复杂度
- python - 如何抓取一个网站的所有首页文字内容?
- github - 为特定元素重新加载 SwiftUI 视图
- python - GCP DLP(数据丢失预防)得到“解密失败:密文无效。”