How to merge a file with several other files, dynamically using grunt?

5

I have a problem that I can not solve in any way. The problem is this:

I use Grunt to automate the tasks of my projects, and in this case, I'm using it as follows:

AsIdidinthedrawingabove,IwouldliketogetalltheJavascriptfilesfromthe"DEV" folder and merge with the "scripts.js" file to result in files with the same name and subdirectory, but located in the "JS ". I wanted to do it all dynamically, with directories and subdirectories.

My (test) code is this:

extras2: {
  options: {
    log: true
  },
  expand: true, // set to true to enable options following options:
  cwd: '<%= dirs.folder %>dev/js', // all sources relative to this path
  src: ['**/*.js', '!**/scripts.js', '!**/_base/**'], // source folder patterns to match, relative to cwd
  dest: '<%= dirs.folder %>js', // destination folder path prefix
  ext: '.js' // replace any existing extension with this value in dest folder
}

Remembering that the script file is in the "dev" folder.

    
asked by anonymous 24.02.2015 / 21:59

1 answer

3

To concatenate the files, you need to include the concat option on your Gruntfile :

concat: {
    options: {
        separator: ';'
    },
    dist: {
        src: ['dev/*.js'],
        dest: 'js/tudojunto.js'
    }
},
    
24.02.2015 / 22:09