命令grunt imagemin将以下内容输出到一个随机文件中。
Fatal error: ENOENT, no such file or directory 'app/public/assets/img/epg/recordseries.png'有趣的是,每次我再次运行grunt命令时,它都会设法处理更多的文件,并以输出关于另一个文件的相同错误结束。
我正在使用
node v0.10.24
npm 1.3.21
grunt@0.4.2
grunt-contrib-imagemin@0.5.0 node_modules/grunt-contrib-imagemin
+-- filesize@2.0.0
+-- async@0.2.9
+-- chalk@0.4.0 (has-color@0.1.2, ansi-styles@1.0.0, strip-ansi@0.1.1)
+-- image-min@0.1.2 (mkdirp@0.3.5, cache-file@0.1.2, mout@0.7.1, optipng-bin@0.3.1, jpegtran-bin@0.2.3, gifsicle@0.1.4)以下是我对imagemin任务的grunt配置:
grunt.config('imagemin', {
options: {
optimizationLevel: 3, // 0 to 7, default =7)
// pngquant: true
},
dynamic: { // Multiple target
files: [{
expand: true, // Enable dynamic expansion
cwd: '<%= context.source %>/assets/img/', // equal to app/wesource/assets/img/
src: ['!**/*-'+arrayToRegexStr(platformIgnoreList)+'**', '**/*.{png,jpg,jpeg,gif}'], // Actual patterns to match //
dest: '<%= context.public %>/assets/img/' // equal to app/public/assets/img/
}]
}
});发布于 2014-01-26 08:01:42
卸载0.5.0版并使用以下命令返回到0.3.0版应可恢复以前的功能:
npm uninstall grunt-contrib-imagemin
npm install --save-dev grunt-contrib-imagemin@0.3.0有一个问题,https://github.com/gruntjs/grunt-contrib-imagemin/issues/140,正在处理中,当它被修复后,应该是安全的升级。
发布于 2014-01-19 17:23:28
以下解决方案适用于...
version
这是一个破解的解决方案,但我发现任务在查看目标目录以查看PNG镜像是否已经存在并进行了优化时失败了。当我一遍又一遍地运行它时,该任务将始终如一地完成,每次它都会多完成一些图像。我可以一遍又一遍地运行grunt clean,然后运行grunt imagemin来重复这个问题。
我看到的错误是:
bash Fatal error: ENOENT, no such file or directory 'build-production/path-to/some-image.png'
解决方案
在优化图像之前,立即将图像复制到目标目录。这样,被复制的检查通过和未优化的图像将被替换为它们的优化等效项。
任务
grunt.task.run(
'copy:imagemin',
'imagemin'
);复制配置
copy: {
imagemin: {
files: [{
expand: true,
cwd: '<%= exponential.client.src %>',
src: ['images/**/*.{png,jpg,gif}'],
dest: '<%= exponential.client.buildProduction %>'
}]
}
}imagemin配置
imagemin: {
buildProduction: {
files: [{
expand: true,
cwd: '<%= exponential.client.src %>',
src: ['images/**/*.{png,jpg,gif}'],
dest: '<%= exponential.client.buildProduction %>'
}]
}
}发布于 2014-02-25 18:19:43
尝试使用cache: false
对我很管用。
https://stackoverflow.com/questions/21175673
复制相似问题