coffeescriptgruntjsgrunt-contrib-watch

Grunt.js, Warning: Unable to write "src" file (Error code: EISDIR)


I have an Gruntfile written in CoffeeScript and I keep getting an (Error code: EISDIR) when the cssmin task is run. After running the task in verbose mode, I get this information:

Running "cssmin" task

Running "cssmin:src" (cssmin) task
Verifying property cssmin.src exists in config...OK
Files: assets/z.styles.concat.css.liquid -> src
Options: report=false
Reading assets/z.styles.concat.css.liquid...OK
Writing src...ERROR
Warning: Unable to write "src" file (Error code: EISDIR). Use --force to continue.

Here's my cssmin task:

 cssmin: 
        src: 'assets/z.styles.concat.css.liquid'
        dest: 'assets/styles.min.css.liquid'

The z.styles.concat.css.liquid is created after concat runs and is successfully outputted to the assets folder. The path listed in the src attribute is correct.

Any idea what could be throwing the error?

Also, here is the entire gruntfile for connivence.

Grunt.coffee:

module.exports = (grunt) ->

# Project configuration.
  grunt.initConfig
    pkg: grunt.file.readJSON 'package.json'

    files:
      grunt:     ['gruntfile.js']
      css:       ['assets/screen.css', 'assets/styles.css.liquid']
      scss:      ['src/scss/**/*.scss']
      js:        ['src/js/**/*.js'] #(if we need liquid templating), 'src/js/**/*.js.liquid', 'assets/**/*.js.liquid']
      coffee:    ['src/js/coffee/**/*.coffee', 'src/js/coffee/**/*.coffee.liquid']
      img:       ['src/images/**/*.{png,jpeg,svg,jpg,gif}']

# Image Processing
    smushit:
      path:  
        src: '<%= files.img %>'  #recursively replace minified images
        dest: 'assets'

# Concatenation Processing
    concat: 
      css: 
        src: ['<%= files.css %>']
        dest: 'assets/z.styles.concat.css.liquid'     

      js: 
        src: ['<%= files.js %>']
        dest: 'src/js/z.scripts.concat.js'


# JavaScript Processing
    coffee:
          app:
            expand: true
            cwd: 'src/js/coffee'
            src: ['**/*.coffee', '**/*.coffee.liquid']
            dest: 'src/js'
            ext: '.js'

    uglify: 
      dist: 
        src: ['src/js/z.scripts.concat.js']
        dest: 'assets/scripts.min.js'

    jshint: 
      files: ['<%= files.grunt %>', 'src/js/z.scripts.concat.js']

      options: 
        jquery: true
        smarttabs: true
        curly: true
        eqeqeq: true
        immed: true
        latedef: true
        newcap: true
        noarg: true
        sub: true
        undef: true
        boss: true
        eqnull: true
        browser: true

      globals: 
        jQuery: true
        console: true
        undef: true
        unused: false



# CSS Processing
    compass: 
      dist: 
        options: 
          sassDir: 'src/scss'
          cssDir: 'assets'
          imagesDir: 'assets',
          javascriptsDir: 'assets',
          outputStyle: 'expanded'   

    cssmin: 
        src: 'assets/z.styles.concat.css.liquid'
        dest: 'assets/styles.min.css.liquid'


# watch tasks
    watch:
      options:
        nospawn: true
        events: ['changed', 'added']
      files: [
                '<%= files.js %>'
                '<%= files.coffee %>'
                '<%= files.scss %>'
            ]
      tasks: ['default']

  # These plugins provide necessary tasks.
  grunt.loadNpmTasks 'grunt-contrib-coffee'
  grunt.loadNpmTasks 'grunt-contrib-watch'
  grunt.loadNpmTasks 'grunt-contrib-concat'
  grunt.loadNpmTasks 'grunt-contrib-jshint'
  grunt.loadNpmTasks 'grunt-contrib-uglify'
  grunt.loadNpmTasks 'grunt-contrib-cssmin'
  grunt.loadNpmTasks 'grunt-smushit'
  grunt.loadNpmTasks 'grunt-contrib-compass'

# Default task.
  grunt.registerTask 'default', [
                      'coffee'
                      'concat:js'
                      'jshint'
                      'uglify'
                      'concat:css',
                      'cssmin'
                    ]

   # Minify task

   # Run the default task then losslessly minify images with Yahoo!'s Smush-It

  grunt.registerTask 'minify', ['default', 'smushit']

Solution

  • In your output Grunt's trying to run the cssmin:src task and then it tries writing to the source file. This can't be the desired result?

    You need to specify a name for the cssmin task because it's a multitask. See the Grunt documentation for additional information.

    Change your grunt config to

    cssmin:
        minify:
            src: 'assets/z.styles.concat.css.liquid'
            dest: 'assets/styles.min.css.liquid'