Comments (20)
Try this:
copy: {
html: {
expand: true,
cwd: 'src/html/',
src: '*',
dest: 'build/html/'
}
}
from grunt-contrib-copy.
Please post the contents of your Gruntfile.
from grunt-contrib-copy.
Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
copy: {
main: {
files: {
//src: ["src/html/*.html"], dest: "build/html/", filter: "isFile"
//"build/html/": ["src/html/*"]
//src: ['src/html/*'], dest: 'build/html/', filter: 'isFile' // includes files in path
//src: ['src/html/**'], dest: 'build/html/' // includes files in path and its subdirs
expand: true, cwd: 'src/html/', src: ['*'], dest: 'build/html/' // makes all src relative to cwd
}
},
watch: {
html: {
files: ["src/html/*.html"],
tasks: ['copy']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask("watch--",["watch"]);
};
from grunt-contrib-copy.
I'm having the same problem. I stripped down my Gruntfile to only show the relevant pieces.
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
copy: {
the-thing: {
files: [
{
src:"../other-project/release/other-project/**",
dest:"main-project/lib/plugins/other-project/"
}
]
}
},
});
grunt.loadNpmTasks('grunt-contrib-copy');
// Default task.
grunt.registerTask('default', ['copy:the-thing']);
};
// The result is a folder structure like this: main-project/lib/plugins/other-project/release/other-project.
// The desired result is: main-project/lib/plugins/other-project.
from grunt-contrib-copy.
@bobspace you need to define a cwd
, please see:
http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
from grunt-contrib-copy.
@niusaul I'm sorry, I don't quite understand the question. Can you please rephrase, or post an example tree listing of what you're trying to get from and to?
from grunt-contrib-copy.
Should the working directory be the source, or destination directory?
from grunt-contrib-copy.
cwd
should be the source path. anything not included in the cwd will be included in the destination files. try running grunt with --verbose to see what you're expanding to if you are confused.
from grunt-contrib-copy.
I want to copy all the files from "src/html/" to "build/html/".
The my-project structure is: "my-project/src/html/some-files.html".
The desired result is: "my-project/build/html/some-files.html"
With options "expand: true, cwd: 'src/html/', src: ['*'], dest: 'build/html/", the undesired result is "my-project/build/html/src/html/some-files.html".
I've also tried all the other options, but still can't get the desired result.
Hope this is clearer.
Thx
from grunt-contrib-copy.
The configuration you've defined there should work fine. Could you please post the console log from running this task with --verbose
please?
from grunt-contrib-copy.
here a new simplified Gruntfile.js, but there's an error that I am trying debugging...
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
copy: {
target: {
options: {
cwd: "src/html/"
},
files: {
"build/html/": ["*.html"]
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask("copy--",["copy"]);
};
error running grunt copy --verbose:
MacPro:template Chinh$ grunt copy --verbose
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Registering "grunt-contrib-copy" local Npm module tasks.
Reading /Users/Chinh/Google Drive/DEV/template/node_modules/grunt-contrib-copy/package.json...OK
Parsing /Users/Chinh/Google Drive/DEV/template/node_modules/grunt-contrib-copy/package.json...OK
Loading "copy.js" tasks...OK
- copy
Loading "Gruntfile.js" tasks...OK - copy--
Running tasks: copy
Running "copy" task
Running "copy:target" (copy) task
Verifying property copy.target exists in config...OK
Files: [no src] -> build/html/
Options: processContent=false, processContentExclude=[], cwd="src/html/"
Done, without errors.
from grunt-contrib-copy.
pls see previous updated comment, no error with different issue "Files: [no src] -> build/html/"
from grunt-contrib-copy.
with the last config above,
if set to "build/html/": [""], I get all the files/dirs of the root
if set to "build/html/": ["*"], I get all the files/dirs/subdirs/subfiles of the root (everything from the root)
from grunt-contrib-copy.
You're the man!
Thank you very much
from grunt-contrib-copy.
:)
from grunt-contrib-copy.
Just had the same issue but @tkellen solution worked for me also. thanks!
from grunt-contrib-copy.
Just a thought...
I often find linking files is an easier method than copying.
Its also much faster than copying files.
Have a look at grunt-shell...
shell: {
link: {
options: {
stdout: true
},
command: 'ln -sF ../vendor ./source/vendor; '
}
}
With this approach I only ever have one real copy of my vendor files.
It is a platform specific option though... works for me on Mac and Debian.
I haven't seen any other down side so far...
from grunt-contrib-copy.
@henrypenny check out grunt-contrib-symlink
from grunt-contrib-copy.
@simshanith even better. :)
from grunt-contrib-copy.
@tkellen very helpful, thank you!
from grunt-contrib-copy.
Related Issues (20)
- hide page HOT 1
- What is it do when copy?
- syncTimestamp running even if timestamp option is false HOT 2
- Document options HOT 1
- Using expand with --no-write fails
- timestampEqual test fails on i386 Linux
- file not copied [no src] HOT 1
- Question than issue
- Copy task not working in windows running forever HOT 5
- Audio files are breaking :'( HOT 1
- Process Function Corrupts Images and fons files
- How to resolve the below error ? HOT 2
- Replace not working with multiple files.
- .filename not copied with src: **/**
- node Assertion failed on copy HOT 3
- Decompose list and move the files in the list to an existing directory
- Xgboost and Bayesian Optimization HOT 1
- Slow on windows HOT 2
- Grunt-Copy-JS annoying Warning: EPERM: operation not permitted, futime Use --force to continue. HOT 2
- Copy files is broken after update Grunt v1.6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-contrib-copy.