Grunt concat files on a different domain or on different server

前端 未结 1 1460
野趣味
野趣味 2021-01-23 07:10

Edit working version and explanation

I want to concat files from different server into my destination folder using grunt, and grunt-concat and

相关标签:
1条回答
  • 2021-01-23 07:25

    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.

    0 讨论(0)
提交回复
热议问题