Skip to content Skip to sidebar Skip to footer

Grunt Concat Files On A Different Domain Or On Different Server

Edit working version and explanation I want to concat files from different server into my destination folder using grunt, and grunt-concat and with something like that: concat: {

Solution 1:

Doesn't look like concat task handles absolute paths or files from remote locations. However I was able to get it to work using curl task combined with the concat task.

EXAMPLE:

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    curl: {
      'download/jquery.js': 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js',
    },
    concat: {
        js: {
            src: ['download/jquery.js'],
            dest: 'output/test.js'
        },
    }
  });

  grunt.loadNpmTasks('grunt-curl');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.registerTask('default', ['curl', 'concat']);
};

DEMO DIRECTORY STRUCTURE:enter image description here

I used this Node Module Package for CURL. https://github.com/twolfson/grunt-curl, there may be better ones out there. But this one seemed to work fine.

Post a Comment for "Grunt Concat Files On A Different Domain Or On Different Server"