我定义了一对copy : {
develop : {
expand : true,
flatten : false,
cwd : "develop/",
src : ["index.html", "gwt/**/*", "!**/*.less", "!**/*.scss", "modules/**/*", "components/**/*", "resources/**/*", "!resources/styles/**"],
dest : "build/"
},
// TODO: figure out how to update glyphicon paths to build
bootstrap_assets : {
expand : true,
flatten : false,
src : ["bower_components/bootstrap-sass/assets/fonts/**/*"],
dest : "build/"
},
}
个任务:
// Intermediate Task - Copy dev resources to build
grunt.registerTask("copy_dev", ["copy:develop", "copy:bootstrap_assets"]);
并将它们组合在自定义任务
中modules
在scss
文件夹中,我想要复制grunt copy:develop
文件中的所有内容。当我运行*.scss
时,它具有我期望的行为,除了grunt copy_dev
之外的所有文件都会复制。但是,当我运行modules
时,grunt copy_dev --verbose
的所有内容都会被复制。
这是Running "copy:develop" (copy) task
Verifying property copy.develop exists in config...OK
Files: develop/modules/front-page -> build/modules/front-page
Files: develop/modules/front-page/front-page.html -> build/modules/front-page/front-page.html
Files: develop/modules/front-page/front-page.scss -> build/modules/front- page/front-page.scss
Files: develop/modules/login -> build/modules/login
Files: develop/modules/login -> build/modules/login
Files: develop/modules/login/bigLogo.png -> build/modules/login/bigLogo.png
Files: develop/modules/login/login-view.html -> build/modules/login/login-view.html
Files: develop/modules/login/login.js -> build/modules/login/login.js
Files: develop/modules/login/login.scss -> build/modules/login/login.scss
Files: develop/modules/login/logo -> build/modules/login/logo
Files: develop/modules/login/logo/lg.png -> build/modules/login/logo/lg.png
Files: develop/modules/login/logo/md.png -> build/modules/login/logo/md.png
Files: develop/modules/login/logo/sm.png -> build/modules/login/logo/sm.png
输出的一部分:
*.scss
如您所见,执行自定义任务时会复制许多copy:$name
个文件,而不是通过常规.find("input")
调用。
为什么会这样?
答案 0 :(得分:2)
你的问题是Grunt从左到右处理你的src / dest指令来构建要复制的文件列表,而不是同时应用所有规则(http://gruntjs.com/configuring-tasks#globbing-patterns),所以:
因此,如果您想要防止所有更少和scss被复制,您需要更改订单:
src : ["index.html", "gwt/**/*", "modules/**/*", "components/**/*", "resources/**/*", "!**/*.less", "!**/*.scss", "!resources/styles/**"]