I want to copy the content of /pckg
to /dist
with grunt.js.
Here is the structure:
|-- folder1
| |
| |-- folder2
| |
| |-- pckg
| |
| |--myfolder
| | |
| | |-- myfiles
| |
| |--myfiles
|
|
|-- dist
|
|--myfolder
| |
| |-- myfiles
|
|--myfiles
Here's my Gruntfile.js
module.exports = function (grunt) {
// Package configuration
grunt.initConfig({
// Metadata
pkg: grunt.file.readJSON('package.json'),
//Copy files
copy: {
main: {
expand: true,
src: 'folder1/folder2/pckg/**',
dest: 'dest/'
}
}
});
// Load the plugin that provides the "copy" task.
grunt.loadNpmTasks('grunt-contrib-copy');
// Default task(s).
grunt.registerTask('default', ['copy']);
};
When I run Grunt, it keep the path. It copy everything in dit/folder1/folder2/pckg
.
What is wrong ?
Thanks for your help !
Concatenating with a custom separator In this example, running grunt concat:dist (or grunt concat because concat is a multi task) will concatenate the three specified source files (in order), joining files with ; and writing the output to dist/built. js . // Project configuration.
Grunt is a JavaScript task runner, a tool used to automatically perform frequent tasks such as minification, compilation, unit testing, and linting. It uses a command-line interface to run custom tasks defined in a file (known as a Gruntfile).
Check with the name, if a task exists in the registered tasks.
In short, Grunt is an open source JavaScript project that automates repetitive tasks you often have to do as a web developer. With Grunt, you can automate tasks like minification, unit testing, and preparing your files and website assets for production use.
Here's what I've used:
copy: {
main: {
expand: true,
cwd: 'folder1/folder2/pckg/',
src: ['**'],
dest: 'dist/'
}
}
use flatten:true
copy: {
main: {
files: [
{expand: true, src: ['components/xxx/*'], dest: 'dist/', flatten: true}
]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With