[英]grunt copy moving build folder outside of project
您好,我有一個看起來像這樣的文件結構,
|-App
|------|src
|----------|js
|----------|img
|----------|css
|----------|less
|----------|tpl
|----------|index.php
|- Gruntfile.js (withing parent app folder)
|- package.json (withing parent app folder)
我想做的是將src文件夾的所有內容移動到build文件夾,創建了build文件夾,但位於App文件夾之外,我真的不明白為什么,其次,當它確實復制src文件夾時,復制實際的src文件夾,我要復制其所有子項,但不復制父級src文件夾,並且第三,副本會忽略index.php文件,為什么? 下面是我當前的Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
copy: {
build: {
cwd: '.',
src: ['src/*/*'],
dest: '../build',
expand: true
}
},
clean: {
build: {
cwd: '.',
src: ['build']
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('move', 'Moves the project to the build folder', ['copy', 'clean']);
};
您的路線是錯誤的。 將build
選項更改為:
build: {
cwd: '.',
src: ['src/**/*'],
dest: './build',
expand: true
}
../build
表示在父目錄中創建了構建目錄( ..
是父目錄) src/**/*
表示遞歸復制所有文件和后代文件夾的文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.