Grunt multi-tasks throwing EISDIR error when building

时光总嘲笑我的痴心妄想 提交于 2019-12-07 03:34:13

问题


I am trying to set up grunt to minify a number of js files in a src directory and copy them to a build directory. Following the grunt task documentation, I believe the below configuration should work.

uglify: {
    dist: {
      files: [
        {
          expand: true,     // Enable dynamic expansion.
          cwd: 'src/js/',   // Src matches are relative to this path.
          src: ['**/?.js'], // Actual pattern(s) to match.
          dest: 'build/minified/',   // Destination path prefix.
          ext: '.min.js'    // Dest filepaths will have this extension.
        }
      ]
    }
  }

When I run grunt I get the message

Running "uglify:dist" (uglify) task Warning: Unable to write "build/minified" file (Error code: EISDIR). Use --force to continue.

If I switch the definition to use manual file paths it works fine. Is the documentation incorrect? or am I using it wrong?

I am running grunt v0.4.0rc2


回答1:


Update grunt and replace src: ['**/?.js'] with src: ['**/*.js']

For more information see the guide on globbing patterns.




回答2:


Had a similar issue where I was getting an issue loading files of the structure:

bower_components/Chart.js/Chart.min.js

Apparently grunt struggles with directories that contain .js in them. I found this solution that fixed my problem: https://github.com/cbas/grunt-rev/issues/29

Basically you explicitly remove the problem directories in the rev section.

i.e, this works:

rev: {
        files: {
            src: [
                'dist/**/*.js',
                '!dist/bower_components/Chart.js',
            ]
        }
    },



回答3:


Modify the detectDestType function in node_modules/grunt-contrib-copy/tasks/copy.js as below:

var detectDestType = function(dest) {
    if (grunt.util._.endsWith(dest, path.sep)) {
      return 'directory';
    } else {
      return 'file';
    }
  };

It should fix the issue.



来源:https://stackoverflow.com/questions/14452751/grunt-multi-tasks-throwing-eisdir-error-when-building

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