我在使用grunt contrib-imagemin时遇到了问题,因为我不能让它压缩任何图像。
这是我的Gruntfile.js
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
src: [
'css/{base,global,medium,large}.css', // All CSS in the CSS folder
],
dest: 'css/build/production.css',
}
},
cssmin: {
build: {
src: 'css/build/production.css',
dest: 'css/build/production.min.css'
}
},
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'if3/images',
src: ['**/*.{png,jpg,gif}'],
dest: 'images/build'
}]
}
}
});
// 3. Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
// 4. Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['concat', 'cssmin', 'imagemin']);
}当我从命令行运行grunt时,concat和cssmin都运行得很好,而imagemin尽管运行没有错误-返回以下消息。
Running "imagemin:dynamic" (imagemin) task
Minified 0 images (saved 0 B)关于信息,我的文件夹结构如下。
if3\
css\
*.css
images\
*.png
*.jpg
js\
*.js
node_modules\
etc.
Gruntfile.js
package.json
*.html图像文件夹目前包含7个PNG和2个JPG文件,但我不明白为什么它不对它们做任何事情。
任何帮助都非常感谢。
谢谢
发布于 2014-12-02 23:38:05
concat和cssmin任务中的src-properties不包含if3。您的imagemin配置可以。去掉它可能会有帮助...
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'images',
src: ['**/*.{png,jpg,gif}'],
dest: 'images/build'
}]
}
} 发布于 2015-10-09 22:54:33
你不需要use: dynamic {}或static {},它会完美的工作。
https://stackoverflow.com/questions/27251529
复制相似问题