kim*_*gro 29 gruntjs grunt-contrib-copy
给出以下源树:
dev
?- psd
?- psd.psd
?- png.png
?- css
?- css.css
?- image
?- 1.jpg
?- 2.png
?html.html
Run Code Online (Sandbox Code Playgroud)
如何复制到pub目录,忽略psd文件夹,如下所示?
pub
?- css
?- css.css
?- image
?- 1.jpg
?- 2.png
?html.html
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法:
{
expand: true,
src: ['dev/**/*', '!dev/psd/**/*'],
dest: 'pub/'
}
Run Code Online (Sandbox Code Playgroud)
但这会导致一个空psd目录
Ati*_*gur 61
请尝试以下Gruntfile.js.它忽略了psd目录.解决方案在以下发现的问题.
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']);
};
Run Code Online (Sandbox Code Playgroud)
示例设置.
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17438 次 |
| 最近记录: |