Grunt uglifym - 超出调用堆栈大小 [英] Grunt uglifym - call stack size exceeded

查看:181
本文介绍了Grunt uglifym - 超出调用堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用uglify和grunt来连接并缩小一些文件。我已经将npm用于 install grunt-contrib-uglify



我的 grunt.js 文件中包含以下内容:(我已经删除了其他一些匿名任务)

  module.exports = function(grunt){

'use strict';

grunt.loadNpmTasks('grunt-contrib-uglify');

uglify:{
选项:{
sourceMap:'app / map / source-map.js'
},
文件:{
'app / dist / sourcefiles.min.js':[
'app / test_js / test.js'
]
}
}

};

然后我运行:

  grunt uglify 

但我继续收到以下错误:

 警告:超出最大调用堆栈大小使用--force继续。 

如果我使用强制,咕噜任务永远不会停止。



有人能告诉我我哪里出错了吗?

解决方案

我有同样的问题,使用另外一个名为recess的Grunt插件。
错误消息不是显式的。

 警告:无法读取未定义的属性'message'使用--force继续。 

但详细模式显示我的任务被称为百次。
问题是我在注册我的任务时创建了循环依赖(导致无限循环)。

> grunt.registerTask('recess',['recess']); //不工作=>循环依赖!

registerTask方法的第一个参数是一个别名任务与第二个参数中定义的任务名称不同。
我改正了这样的情况:

pre $ g code> grunt.registerTask('my-recess-task',['recess']] );

我运行调用此任务的任务(在命令提示符窗口中)

  grunt my-recess-task 



<



有关registerTask()方法,来自grunt API:
http://gruntjs.com/api/grunt.task#grunt.task.registertask


I am trying to use uglify with grunt to concat and minify some files. I have already used the npm to install grunt-contrib-uglify.

I have the following in my grunt.js file: (I have removed some other tasks for anonymity)

module.exports = function(grunt) {

  'use strict';      

    grunt.loadNpmTasks('grunt-contrib-uglify');

    uglify: {
        options: {
            sourceMap: 'app/map/source-map.js'
        },
        files: {
            'app/dist/sourcefiles.min.js': [
                'app/test_js/test.js'
              ]
        }
    }

};

I then run:

grunt uglify

but I keep getting the following error:

Warning: Maximum call stack size exceeded Use --force to continue.

If I use force, the grunt task never stops running.

Can someone tell me where I am going wrong? I am tearing my hair out on this one.

解决方案

I had the same problem, using an other Grunt plugin called recess. The error message was not explicit.

Warning: Cannot read property 'message' of undefined Use --force to continue.

But the verbose mode showed that my task was called hundred of times. The problem was that I created a "cyclic dependency" (causing an infinite loop) when I registered my task.

grunt.registerTask('recess', ['recess']); //does not work => cyclic dependency! 

The first parameter of registerTask method is an "alias task" and has to be different from the task names defined in the second parameter. I corrected like this:

grunt.registerTask('my-recess-task', ['recess']);

And I runned the task calling this (in the Command prompt window)

grunt my-recess-task

And then it was OK!

More about registerTask() method, from grunt API: http://gruntjs.com/api/grunt.task#grunt.task.registertask

这篇关于Grunt uglifym - 超出调用堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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