我决定优化我的CSS文件。找到了一个名为UNCSS的库,它与Grunt一起运行。 问题是我没有使用命令行,但我的知识水平很低。 我正在运行Windows 7 X64,而且我已经为Windows安装了git。它很好地与windows命令行集成。所以我的工作流程是: 1)。使用Windows安装程序安装Grunt 2)。使用命令提示符导航到我的项目文件夹 3)。我运行了这些命令:
npm install grunt --save-dev
npm install grunt-uncss --save-dev
4)。项目文件夹包含以下文件夹:
node_modules->grunt
node_modules->grunt-uncss
我在项目的根文件夹中创建了Gruntfile.js文件:
module.exports = function(grunt) {
grunt.initConfig({
uncss: {
dist: {
files: {
'css/style.css': ['index.html']
}
}
}
});
grunt.loadNpmTasks('grunt-uncss');
//grunt.registerTask('default', 'uncss');
grunt.registerTask('default', ['uncss']);
};
5)。运行grunt
或grunt uncss
命令会引发Warning: Task "default\uncss" not found. Use --force to continue.
我唯一需要的是扫描和优化我的项目并使其简单...
我无法弄清楚我做错了什么。搜索了教程,但它们是相同的......