问题描述
我使用从我的项目中删除了冗余css。对于每个引用不同CSS文件的HTML页面,我试图为每个HTML页面创建一个CSS文件。这里我只显示两个文件,但真正的我工作在大约370个文件。这是我目前的程式码
I am using grunt-uncss to remove redundant css from my project. For every HTML page referencing different css files, I am trying to create one css file for every html page. Here I am showing only two files but for real I am working with around 370 files. Here is my current code
uncss: {
dist: {
files:
{
'./newcss/75.css': ['./4dlife/src/app/views/com/twenty/todoPido.html'],
'./newcss/351.css': ['./4dlife/tools/experiments/index.html']
},
options: {
compress:true
}
}
}
});
但是, todoPido.html
css文件,因此我的输出是
However, the todoPido.html
has no css files and hence my output is
但是当我执行此
However when I run this
uncss: {
dist: {
files:
{
'./newcss/351.css': ['./4dlife/tools/experiments/index.html']
},
options: {
compress:true
}
}
}
});
我得到了 index.html
。
完成,没有错误。
我不明白的是我做错了。它工作正常,当我给一个文件,但失败,当我添加多个文件。我究竟做错了什么?而且,如何删除 ReferenceError:找不到变量:require
?
What I can not understand is what am I doing wrong. It works fine when I give one file but fails when I add multiple files. What am I doing wrong? And also, how to remove the ReferenceError: Can't find variable: require
?
推荐答案
uncss: {
dist: {
// files: {
// '<%= config.dist %>/styles/main.css': ['<%= config.dist %>/index.html'],
// '<%= config.dist %>/styles/blog.css': ['<%= config.dist %>/blog.html']
// }
files: [
{
src: ['<%= config.dist %>/index.html'],
dest: '<%= config.dist %>/styles/main.css'
},
{
src: ['<%= config.dist %>/blog.html'],
dest: '<%= config.dist %>/styles/blog.css'
}
]
}
},
这篇关于如何在grunt-css中添加多个css文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!