Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt multi-tasks throwing EISDIR error when building

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

like image 763
madcapnmckay Avatar asked Jan 22 '13 06:01

madcapnmckay


2 Answers

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

For more information see the guide on globbing patterns.

like image 131
mutil Avatar answered Sep 23 '22 18:09

mutil


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',
            ]
        }
    },
like image 43
JackB Avatar answered Sep 21 '22 18:09

JackB