Grunt将文件夹作为文件处理(Grunt is treating folder with a dot as a file)

编程入门 行业动态 更新时间:2024-10-27 18:32:39
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这是一个包含文件而不是文件本身的目录?

When trying to compile my grunt file and build into my dist folder for deployment I get the following error in the console:

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).

The reason for this is that I have a bower component I've got installed named animate.css. This library is of course installed in my bower_components folder, but the matching string I have in my Grunt file only looks for files with an extension of .js, .css, et cetera. Here's my matching string:

// 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/*' ] } } }

And here's the directory structure:

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 -> ...

In this case, how would I tell Grunt that this is a directory which contains files rather than a file itself?

最满意答案

我有一些不同的方法。

bower install animate-css --save

它会抓住animate.css,但保存在:

bower_components/animate-css

使用这种方法,你不必使用Gruntfile.js,我个人认为它不适合编辑,甚至看;)

I have slightly different approach.

bower install animate-css --save

it will grab animate.css but save at:

bower_components/animate-css

Using this method you don't have to play with Gruntfile.js which I personally consider unpleasant to edit and even look at ;)

更多推荐

本文发布于:2023-07-22 12:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219997.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   文件   Grunt   treating   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!