无法编译;使用grunt响应式图像找不到有效的源文件

时间:2016-04-29 18:22:50

标签: javascript node.js gruntjs

我在Jekyll网站上使用grunt responsive-images

GitHub上的相关issue现已关闭,但我仍然收到此错误。 srccwd都指向单个test.jpg图片。

当我运行grunt responsive_images:posts时,我得到无法编译;找不到有效的源文件。

gruntfile示例:

  ...
  responsive_images: {
    posts: {
      options: {
        engine: 'im',
        sizes: [
          { name: 'small', width: 320, quality: 80 }
        ]
      },
      files: [
        {
          expand: true,
          src: [ '_assets/posts/**{.jpg}' ],
          cwd: '_assets/posts/',
          dest: 'img/'
        }
      ]
    }
  },
  ...

Grunt依赖项:

{
  "name": "corporate-programmer",
  "version": "1.0.0",
  "devDependencies": {
    "bootstrap-sass": "^3.3.6",
    "grunt": "^1.0.1",
    "grunt-concurrent": "^2.3.0",
    "grunt-contrib-clean": "^1.0.0",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-sass": "^1.0.0",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-responsive-images": "^0.1.7",
    "grunt-shell": "^1.3.0",
    "load-grunt-tasks": "^3.5.0"
  }
}

文件结构示例:

enter image description here

详细输出:

Verbose output when running task

> npm -v
> 2.7.4

> npm list imagemagick -g
> └── imagemagick@0.1.3

1 个答案:

答案 0 :(得分:1)

src通常相对于cwd中定义的路径,将您的src值更新为**/*.js

responsive_images: {
    posts: {
      options: {
        engine: 'im',
        sizes: [
          { name: 'small', width: 320, quality: 80 }
        ]
      },
      files: [
        {
          expand: true,
          src: [ '**/*.jpg' ],
          cwd: '_assets/posts/',
          dest: 'img/'
        }
      ]
    }
  },