简体   繁体   中英

Unable to write “css” file (Error code: EISDIR) Grunt cssmin

I have defined a uncss grunt task, I want add .min.css to all my files content in the folder /css, but when I run grunt command and save my css changes (the task watch is looking), I get the following error in console:

Unable to write "css" file (Error code: EISDIR

This is my cssmin task:

// Cssmin task config
    cssmin: {
      target: {
        files: [{
          src: ['css/*.css', 'css/!*.min.css'],
          dest: 'css',
        }]
      }
    }

And this is my complete Gruntfile.js:

//Gruntfile.js
module.exports = function (grunt) {
  grunt.initConfig({

    // Watch task config con Sass
    watch: {
      sass: {
        files: "scss/*.scss",
        tasks: ['sass']
      },
      cssmin: {
        files: "css/*.css",
        tasks: ['cssmin']
      }
    },

    // Sass task config
    sass: {
        dev: {
            files: {
                // fichero destino  // fichero .scss
                "css/custom.css" : "scss/custom.scss"
            }
        }
    },

    // BrowserSync task config
    browserSync: {
      default_options: {
        bsFiles: {
          src: [
            "css/*.css",
            "js/*.js",
            "*.html"
          ]
        },
        options: {
          watchTask: true,
          proxy: "tutorialmaterialize.dev"
          }
        }
      },

    // UnCSS task config  
    uncss: {
        dist: {
            options: {
               //Estilos que queremos limpiar
               stylesheets : ['css/materialize.min.css'],

               //Estilos que no queremos limpiar
               ignoreSheets: [/custom.css/], 
            },
            files: {
                    //Archivo css de salida    //Scanea las clases, ids, etc de este html
                    'css/materialize.min.css': ['index.html']
            }
        }
    },

    // Cssmin task config
    cssmin: {
      target: {
        files: [{
          src: ['css/*.css', 'css/!*.min.css'],
          dest: 'css',
        }]
      }
    }

    });

  //Cargamos los grunt plugins
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-browser-sync');
  grunt.loadNpmTasks('grunt-uncss');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

 //Tarea por defecto
 grunt.registerTask('default', ['browserSync', 'watch']);
};

Finally this is my project structure:

 materialize-css/
  |--css/
  |  |--materialize.min.css
  |  |--custom.css
  |
  |--img/
  | 
  |--fonts/
  |  |--material-design-icons
  |  |--roboto 
  |
  |--js/
  |  |--materialize.min.js
  |
  |--index.html

How can I fix this?

i had similar issue i solved it by changing dest path to /css

cssmin: {
    options: {
        compatibility: 'ie9'
    },
    compress: {
        src: ['css/reveal.css', 'css/main.css'],
        dest: '/css'
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM