Grunt concat文件位于不同的域或不同的服务器上 [英] Grunt concat files on a different domain or on different server

查看:126
本文介绍了Grunt concat文件位于不同的域或不同的服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑工作版本和说明

我想用不同的服务器将文件连接到目标文件夹grunt和grunt-concat以及类似的东西:

  concat:{
options:{
分隔符:';'
},
dist:{
src:['dev.staticcontent.com/media/clientcontent/library/*.js','js / *。js' ],
dest:'dist /<%= pkg.name%> .js'
}
},

每次尝试时,我都没有收到grunt的错误,但是我的 dist / marketing-home.js 文件是空......就像没有找到任何东西。

控制台:

  C:\Project\My> grunt 
运行jshint:files(jshint)任务
>> 1个文件免费。

运行concat:dist(concat)任务
创建文件dist / marketing-home.js。

运行uglify:dist(uglify)任务

完成,没有错误。

新版本

在Kris的帮助下,我可以在不通过网络的情况下使用 grunt-exec 并使用 COPY XCOPY shell命令。



ex。

  exec:{
copy:{
cmd:function(){
var path =\\\\dev -server123\\WebSites\\Static_Contents\\Media\\clientcontent;
返回copy dist \\ * .min.js+ path +/ y;




解决方案

看起来不像concat任务处理绝对路径或来自远程位置的文件。不过,我可以使用curl任务与concat任务结合使用。



示例:

  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']);
};

演示目录结构



我为CURL使用了这个节点模块包。 https://github.com/twolfson/grunt-curl ,可能会有更好的那里。但是,这似乎工作得很好。


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: {
      options: {
        separator: ';'
      },
      dist: {
        src: ['dev.staticcontent.com/media/clientcontent/library/*.js', 'js/*.js'],       
        dest: 'dist/<%= pkg.name %>.js'
      }
    },

each time I tried, I received no error from grunt, but my dist/marketing-home.js file is empty... Like it didn't find anything.

Console:

C:\Project\My>grunt 
Running "jshint:files" (jshint) task
>> 1 file lint free.

Running "concat:dist" (concat) task
File dist/marketing-home.js created.

Running "uglify:dist" (uglify) task

Done, without errors.

New Version

After the help of Kris, I was able to do it without passing through the web using grunt-exec and doing using COPY or XCOPY shell command.

ex.

   exec: {
     copy : {
        cmd: function () {
               var path = "\\\\dev-server123\\WebSites\\Static_Contents\\Media\\clientcontent";
               return "copy dist\\*.min.js " + path + " /y";
        }
     }
   }

解决方案

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:

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.

这篇关于Grunt concat文件位于不同的域或不同的服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆