Grunt uglifym - call stack size exceeded

不打扰是莪最后的温柔 提交于 2019-12-22 09:01:44

问题


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.


回答1:


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




回答2:


I also met this problem, i solved this by removing grunt.registerTask('uglify', ['uglify']);

before i solved this, i ran grunt uglify -v to check what happend.

I found it because that where you using this grunt.loadNpmTasks('grunt-contrib-uglify'); ,it implicitly executes the grunt.registerTask('uglify', ['uglify']); ^_^



来源:https://stackoverflow.com/questions/17033246/grunt-uglifym-call-stack-size-exceeded

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!