您好,我有一个如下所示的文件结构,
|-App
|------|src
|----------|js
|----------|img
|----------|css
|----------|less
|----------|tpl
|----------|index.php
|- Gruntfile.js (withing parent app folder)
|- package.json (withing parent app folder)
我想做的是将 src 文件夹的所有内容移动到构建文件夹中,构建文件夹被创建,但在 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: {
cwd: '.',
src: ['src/**/*'],
dest: './build',
expand: true
}
../build
表示构建目录是在父目录中创建的(..
是父目录)src/**/*
表示递归复制所有文件以及后代文件夹的文件。
关于javascript - grunt 复制将构建文件夹移动到项目之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26969851/