0

There is source folder and publish folder in the project. I want to copy all files and folders from source to publish.

enter image description here

Related code from Gruntfiles.js:

grunt.initConfig({
        copy: {
          main: {
            files: [
              { src: ['source/**/*'], dest: 'publish/'},
              ]
          }
      }
});

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.registerTask('default', ['copy']);

However it copies source folder itself and puts in publish folder.

enter image description here

Tried a lot of variations from grunt-copy documentation and cannot find solution.

4

2 回答 2

1

试试这个配置:

grunt.initConfig({
    copy: {
        main: {
            cwd: 'source',
            src: ['**/*'],
            dest: 'publish/',
            expand: true
        }
    }
});
于 2014-11-03T12:31:08.487 回答
0

如果您只想复制 SRC 的某些部分并在正常流程(SASS、CONCAT、MINIFY 插件)上构建其他部分,您可以选择:

copy: {
  main: {
    files: [
      {expand: true, cwd: '../src/', src: ['images/*'], dest: '../public/images'},
      ...
    ]
  }
}

上面的关键点是 CWD,它允许您按原样复制文件夹,而不是在“public”中复制“src”。

于 2015-03-21T20:04:12.330 回答