无法写" css"文件(错误代码:EISDIR)Grunt cssmin

时间:2015-08-11 18:50:34

标签: javascript html css gruntjs grunt-contrib-cssmin

我已经定义了一个unss grunt任务,我想将.min.css添加到文件夹/ css中的所有文件内容,但是当我运行grunt命令并保存我的css更改(任务监视正在查看)时,我得到了控制台中出现以下错误:

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

这是我的cssmin任务:

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

这是我完整的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']);
};

最后这是我的项目结构:

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

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我有类似的问题,我通过将dest路径更改为/css

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