簡體   English   中英

grunt復制將構建文件夾移動到項目外部

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM