jney
jney

Reputation: 1912

how to concat strings and files using gruntjs

Is it possible to concat strings using grunt ? I know that i can concat <banner> like this :

concat: {
  dist: {
    src: [
      '<banner>',
      '<file_strip_banner:public/src/js/lib/underscore.js>',
      '<file_strip_banner:public/src/js/lib/jquery.js>'
    ],
    dest: 'public/js/all.js'
  }
}

but when i declare other variables in the meta they are just ignored.

Thanks

Upvotes: 1

Views: 1146

Answers (1)

Kyle Robinson Young
Kyle Robinson Young

Reputation: 13762

Yes. Just specify the location in your banner directive. Here is an example grunt.js:

grunt.initConfig({
  meta: {
    banner: '/* I am a string */',
    footer: '/* Im another string at the bottom! */'
  },
  concat: {
    dist: {
      src: [
        '<banner:meta.banner>',
        '<file_strip_banner:public/src/js/lib/underscore.js>',
        '<file_strip_banner:public/src/js/lib/jquery.js>',
        '<banner:meta.footer>'
      ],
      dest: 'public/js/all.js'
    }
  }
});

Be aware that all directives such as <banner> and <file_strip_banner> have been removed in Grunt v0.4... so this will only work in Grunt v0.3.

Upvotes: 3

Related Questions