- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我继承了一个网站,其中包含几个巨大的 css 文件,使用 Firefox 中的 DUst-Me Selector 进行分析后,我返回了将近 2000 个未使用的样式。
要删除它们,我正在尝试使用 grunt uncss,问题是我收到以下错误:
grunt uncss
Running "uncss:dist" (uncss) task
Fatal error: uncss/node_modules/css: missing '}' near line 2429:5
-> .mobile-hidden {
这些是我的配置文件
package.json
{
"name": "tappr-registration",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-copy": "^0.7.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-uglify": "^0.6.0",
"grunt-processhtml": "^0.3.3",
"grunt-uncss": "^0.3.7"
}
}
Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uncss: {
dist: {
options: {
media: ['min-width'],
timeout: 1000,
htmlroot: 'public_html',
report: 'max'
},
files: {
'dist/clean.css': ['public_html/index.php', 'public_html/page_2.html', 'public_html/page_3.html']
}
}
}
});
// Load the plugin that provides the "uncss" task.
grunt.loadNpmTasks('grunt-uncss');
grunt.loadNpmTasks('grunt-processhtml');
grunt.registerTask('default', ['uncss','processhtml']);
};
现在,我最好的猜测是我收到此错误是因为我以错误的方式指定了要包含的媒体查询,但我还没有找到一些关于 uncss 如何需要该选项的合适文档。
我已经尝试取消选项。
有人有好的建议吗?
最佳答案
信不信由你,问题是由评论引起的:
<!-- ----- Responsive 34.2857142857em ------>
之后我将它们移除,一切正常,我可以说这是非常需要的。
Running "uncss:dist" (uncss) task
File cleancss/tidy.css created: 229.48 kB → 25.98 kB
:)
关于javascript - 尝试使用 grunt uncss 删除一些 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27163905/
我正在使用 多类选择器 对于我的 angular js 应用程序中的某些元素,如下所示: som text 在我的 CSS 文件中,我有 .first 和 .first.second 的其他更具体的属
我正在尝试使用 uncss 删除 css但它会删除所有样式,无论它们是否列在 ignore 数组中。 我想要比较的 2 个文件只是索引和 app.min.js,其中包含作为字符串嵌入 javascri
我需要在 UnCSS 中传递表单数据以登录到我的网站访问控制区域,但是我似乎找不到任何有关如何执行此操作的示例。我知道 UnCSS 使用 PhantomJS,我已经很容易地让 PhantomJS 做到
忽略选项似乎对我不起作用。 我正在执行以下操作: .pipe(plugins.uncss({ html: glob.sync('./**/*.{csh,h}tml'),
我正在使用 grunt-uncss 清理我正在处理的 bootstrap/angularjs 元素中的 css 选择器。我正在使用 urls 选项,因为我需要 uncss 在运行时解析 css,因为它
我正在尝试对我所有的 js 和 css 文件使用 gulp-uncss。只有 css 文件才能正常工作,问题是我的 application.js 具有以下结构: "use strict"; (func
我已经编写了 grunt uncss 任务来删除代码中未使用的 css。但是它删除了我的代码中使用的很多 css。我想原因是,它没有检查指令 'my-directive' 中的 css这是我的 ind
我是 gulp 和 uncss 的新手,不确定我的逻辑是否有缺陷,或者我需要的东西是否不可能。 我希望 uncss 忽略大量以特定字符串为前缀的 CSS 规则,但它们的声明中链接了许多复合选择器。 我
我正在尝试通过使用 uncss 删除我正在使用的框架中所有未使用的 css。但是当我尝试时出现错误: file:///C:/Users/Angus/Desktop/FTTL%20website%20s
我尝试使用 grunt 配置 uncss 我已经安装了 npm install grunt-uncss --save-dev npm install grunt-processhtml --save-
我有 uncss(github 上的一个元素)来删除响应式网站不需要的 css。它还会删除 mobile.css 文件中提到的 css,但它实际上会影响移动 View 中的站点。我不知道 uncss
与 uncss我们可以从样式表中删除未使用的 css。它通过查看要部署的 html 文件并仅打包使用的 css 规则来工作。 Angular 4 有像这样应用条件 css 的指令: 任何人都知道是否
我是 grunt 的新手,我正在努力学习它。如果我有 index.html 文件要处理,这有点简单,但我没有,我有 index.php - 所以我试过了: uncss: { dist: {
我想使用 grunt 插件“uncss”。但我仍然错过了 Bootstrap 模式的一些类。现在我的 uncss grunt 设置如下所示: uncss: { dist: {
我有一个使用 React 的项目,我想修剪我的 CSS 构建文件。 React 没有 html 文件,所以我不知道如何让 UnCSS 与 React 一起工作。我可以将 React 与 UnCSS 一
我正在使用 gulp uncss。这是我的任务代码: gulp.task('uncss', () => { return gulp.src($uncss.src) .pipe(uncss(
我遇到了一些正则表达式问题。 使用 gulp-uncss 我想向忽略选项添加一些类。 任何以 .no- 开头的类 任何包含 .is- 的类 .no-flexbox {} .test.is-active
我一直在通过谷歌寻找一种方法来做我想做的事,但没有成功。 这是我的 gulp 任务 gulp.task('less', function() { return gulp.src('cs
我继承了一个网站,其中包含几个巨大的 css 文件,使用 Firefox 中的 DUst-Me Selector 进行分析后,我返回了将近 2000 个未使用的样式。 要删除它们,我正在尝试使用 gr
正如预期的那样,当我在我的 index.html 文件上运行 gulp uncss 时,它从我的样式表中删除了所有未在 html 中使用的 css 规则。问题是我的应用程序主要是 javascript
我是一名优秀的程序员,十分优秀!