Grunt将带点的文件夹视为文件
Grunt is treating folder with a dot as a file
当试图编译我的grunt文件并构建到我的dist
文件夹中进行部署时,我在控制台中收到以下错误:
Running "rev:dist" (rev) task
dist/public/app/app.js >> 63decaf3.app.js
dist/public/app/vendor.js >> a09756ab.vendor.js
dist/public/app/app.css >> d2017fc8.app.css
Warning: Unable to read "dist/public/bower_components/animate.css" file (Error code: EISDIR).
原因是我安装了一个名为animate.css的bower组件。这个库当然安装在我的bower_components
文件夹中,但我在Grunt文件中的匹配字符串只查找扩展名为.js
、.css
等的文件。这是我的匹配字符串:
// Renames files for browser caching purposes
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/public/{,*/}*.js',
'<%= yeoman.dist %>/public/{,*/}*.css', // Offending line
'<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%= yeoman.dist %>/public/assets/fonts/*'
]
}
}
}
这是目录结构:
bower_components
-> ...
-> angular-ui-router
-> animate.css // Folder with the error
---> animate.css // File that it should be recognizing
---> animate.min.css // File that it should be recognizing
-> es5-shim
-> ...
在这种情况下,我如何告诉Grunt这是一个包含文件而不是文件本身的目录?
我的方法略有不同。
bower install animate-css --save
它将抓取animate.css,但保存在:
bower_components/animate-css
使用这种方法,你不必玩Gruntfile.js,我个人认为编辑甚至看它都很不愉快;)
排除animate.css
文件夹,然后包括其中的所有内容。我不确定具体的glob选项,请参阅此处,了解详细信息。类似这样的东西:
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/public/{,*/}*.js',
'<%= yeoman.dist %>/public/{,*/}*.css',
'!<%= yeoman.dist %>/public/bower_components/animate.css',
'<%= yeoman.dist %>/public/bower_components/animate.css/animate.css',
'<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%= yeoman.dist %>/public/assets/fonts/*'
]
}
}
}
您应该能够使用带有fs的自定义筛选函数。Stats方法。此外,还有ext
选项(指示划分扩展的周期所在的位置。)
ext:String
src: [
'<%= yeoman.dist %>/public/{,*/}*.js',
'<%= yeoman.dist %>/public/{,*/}*.css', // Offending line
'<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%= yeoman.dist %>/public/assets/fonts/*'
],
filter: 'isDirectory',
您可能需要使用isFile
,具体取决于是否只想匹配实际文件。
isFile的使用示例,对我来说很有魅力。
// Renames files for browser caching purposes
filerev: {
dist: {
src: [
'<%= yeoman.dist %>/**/*.js',
'!<%= yeoman.dist %>/local.js',
'!<%= yeoman.dist %>/web.js',
'<%= yeoman.dist %>/styles/**/*.css',
'<%= yeoman.dist %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}',
'<%= yeoman.dist %>/styles/fonts/*'
],
filter: 'isFile'
}
},
相关文章:
- 将配置文件文件夹移动到sdcardfirefoxmobile14.0
- Grunt imagemin-观察多个文件/文件夹优化单个文件
- Angular 2-模型驱动的表单,带有输入文件(文件上传)
- 将整个JavaScript文件文件夹添加到HTML5应用程序缓存中
- HTML或JavaScript,如何找出程序文件文件夹的位置
- 使用 OS 在 JavaScript 中预置文件.文件
- 使用纯 JavaScript 创建文件/文件夹
- 基本脚本,它向自己发送一封包含从文件文件夹中随机选择的内容的邮件
- 巴贝尔节点不't编译时忽略指定的文件/文件夹
- 在以下场景中,如何使代码可用于多个文件文件对象
- Chrome拖放文件/文件夹不工作
- Bootstrap fileinput删除所有文件文件,而不是要删除的特定预览文件
- 如何在SonarQube 4.4's技术债务计算中忽略文件/文件夹?
- OneDrive for Business是否有客户端javascript库提供文件/文件夹选择器控件?
- 将文件从插件复制到配置文件文件夹
- 从sd卡复制目录到“文件”;文件夹中
- 逐行读取上传的文件.文件,使用cfs:gridfs存储)
- 配置grunt copy任务,排除文件/文件夹
- 用于检查CSS和JS文件文件夹的工具
- gruntjs:将文件+文件夹重命名为任务