gpt4 book ai didi

javascript - 尝试使用 grunt uncss 删除一些 css

转载 作者:行者123 更新时间:2023-11-28 17:26:09 26 4
gpt4 key购买 nike

我继承了一个网站,其中包含几个巨大的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com