给出以下源代码树:
dev
丨- psd
丨- psd.psd
丨- png.png
丨- css
丨- css.css
丨- image
丨- 1.jpg
丨- 2.png
丨html.html
如何复制到pub目录,忽略psd文件夹,如下所示?
pub
丨- css
丨- css.css
丨- image
丨- 1.jpg
丨- 2.png
丨html.html
我尝试了以下内容:
{
expand: true,
src: ['dev/**/*', '!dev/psd/**/*'],
dest: 'pub/'
}
但是这导致了一个空的psd
目录
答案 0 :(得分:61)
尝试关注Gruntfile.js。它忽略了psd目录。在以下question中找到解决方案。
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
copy: {
main: {
src: ['**/*', '!**/psd/**'],
expand: true,
cwd: 'dev',
dest: 'pub',
}
}
});
// Load the plugin that provides the "copy" task.
grunt.loadNpmTasks('grunt-contrib-copy');
// Default task(s).
grunt.registerTask('default', ['copy']);
};
示例设置。
mkdir gruntQuestion1
cd gruntQuestion1/
mkdir dev
mkdir dev/psd
mkdir dev/css
mkdir dev/image
touch dev/html.html
touch dev/psd/psd.psd
touch dev/psd/png.png
touch dev/css/css.css
touch dev/image/1.jpg
touch dev/image/2.png
atilla$ rm -rf pub/
atilla$ grunt
Running "copy:main" (copy) task
Created 2 directories, copied 4 files
Done, without errors.
atilla$ tree pub/
pub/
├── css
│ └── css.css
├── html.html
└── image
├── 1.jpg
└── 2.png
2 directories, 4 files