Grunt用点作为文件来处理文件夹

cer*_*eny 9 javascript glob gruntjs animate.css yeoman

当我尝试编译我的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).
Run Code Online (Sandbox Code Playgroud)

原因是我有一个名为animate.css的安装了bower组件.该库是安装在我当然bower_components文件夹,但匹配的字符串我在咕噜文件只查找文件具有的扩展.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/*'
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这是目录结构:

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
  -> ...
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我如何告诉Grunt这是一个包含文件而不是文件本身的目录?

小智 7

我的方法略有不同.

bower install animate-css --save

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

bower_components/animate-css

使用这种方法你不必使用Gruntfile.js,我个人认为编辑甚至看起来都不愉快;)


use*_*789 6

排除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/*'
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)