我对 Grunt.js 比较陌生,设置起来很简单,但现在我有两个问题:1)首先,你如何跟踪给定源文件夹中的任何文件夹?例如,图像文件夹本身可能包含图像,以及带有图像的文件夹和带有图像的文件夹等。2)有没有办法在它的主要(构建)文件夹中查看图像?没有任何永远循环...
这是我当前的配置:
module.exports = function(grunt) {
grunt.initConfig({
jsDir: 'sources/js/',
jsDistDir: 'public/js/',
cssDir: 'sources/css/',
cssDistDir: 'public/css/',
concat: {
js: {
src: ['<%=jsDir%>*.js'],
dest: '<%=jsDistDir%>javascript.js'
},
css: {
src: ['<%=cssDir%>*.css'],
dest: '<%=cssDistDir%>styles.css'
}
},
min: {
dist: {
src: ['<%= concat.js.dest %>'],
dest: '<%=jsDistDir%>javascript.js'
}
},
cssmin: {
dist: {
src: ['<%= concat.css.dest %>'],
dest: '<%=cssDistDir%>styles.css'
}
},
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'sources/images/',
src: ['**/*.{png,jpg,gif}'],
dest: 'public/images/'
}]
}
},
watch: {
min: {
files: ['<%=jsDir%>*.js'],
tasks: ['concat:js', 'min']
},
cssmin: {
files: ['<%=cssDir%>*.css'],
tasks: ['concat:css', 'cssmin']
},
imagemin: {
files: ['sources/images/**/*.{png,jpg,gif}'],
tasks: ['imagemin']
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-yui-compressor');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'concat',
'min',
'cssmin',
'imagemin',
'watch'
]);
};
谢谢!