Grunt扩展文件,src中可以接受哪些模式? [英] Grunt expand files, what patterns are acceptable in src?
本文介绍了Grunt扩展文件,src中可以接受哪些模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
sass:{
compile:{
files:[{
展开:true,
cwd:'css /',
src:['^ [^ _]。scss'],
dest:'../css/' ,
ext:'.css'
}]
}
},
根据rubular,这应该工作在。
基本上我想编译'css'目录中的所有.scss文件,除非它们以下划线开头。然而,这种模式不匹配任何东西?
任何想法?
解决方案
试试这个模式: ['*。scss','!_ *。scss']
。这将使得区别更加明确。
sass:{
compile:{
files :[{
expand:true,
cwd:'css /',
src:['* .scss','!_ *。scss'],
dest: '../css/',
ext:'.css'
}]
}
},
$ b $ p 如果要递归匹配( cwd
子文件夹中的文件),请使用 ** / *
sass:{
compile:{
files:[ {
expand:true,
cwd:'css /',
src:['** / *。scss','!** / _ *。scss'],
dest:'../css/',
ext:'.css'
}]
}
},
详细了解 Grunt Globbing Patterns ,与正式表达式不一样sions 。
Snippet from gruntfile.js
sass: {
compile: {
files: [{
expand: true,
cwd: 'css/',
src: ['^[^_].scss'],
dest: '../css/',
ext: '.css'
}]
}
},
This should work according to rubular.
Basically I want to compile all .scss files in the 'css' directory, unless they start with an underscore. However, that pattern doesn't match anything?
Any ideas?
解决方案
Try this pattern: ['*.scss', '!_*.scss']
. It'll make the distinction more explicit, too.
sass: {
compile: {
files: [{
expand: true,
cwd: 'css/',
src: ['*.scss', '!_*.scss'],
dest: '../css/',
ext: '.css'
}]
}
},
If you want to match recursively (files in subfolders of cwd
), use **/*
sass: {
compile: {
files: [{
expand: true,
cwd: 'css/',
src: ['**/*.scss', '!**/_*.scss'],
dest: '../css/',
ext: '.css'
}]
}
},
Learn more about Grunt Globbing Patterns, which aren't the same as regular expressions.
这篇关于Grunt扩展文件,src中可以接受哪些模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文