我已经定义了一个uncss grunt任务,我想在文件夹/css中添加.min.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
我该如何解决这个问题?
我有类似的问题,我通过将dest路径更改为/css
来解决它
cssmin: {
options: {
compatibility: 'ie9'
},
compress: {
src: ['css/reveal.css', 'css/main.css'],
dest: '/css'
}
}