一、总结
我无法设置grunt-clean-console插件,它适用于我的所有.html
文件。
2. 细节
grunt-clean-console 检查.html
文件的浏览器控制台错误。
我想检查.html
我网站上所有文件的浏览器控制台错误。在我阅读的官方描述中,插件如何针对特定的url
键值工作。我的网站上有很多页面;我不想.html
单独添加每个文件。但我找不到,我如何使用模式。
我发现,我可以使用内置 Grunt cwd
、src
、dest
键的模式。url
但是,从这个插件开始,我如何使用 glob(或其他)模式作为自定义键?
3. 数据
Gruntfile.coffee
:module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-clean-console' grunt.initConfig 'clean-console': all: options: url: 'output/index.html' return
示例项目配置:
output │ 404.html │ index.html │ ├───KiraFirstFolder │ KiraFirstfile.html │ └───KiraSecondFolder KiraSecondFile.html
如果我像上面的示例那样为没有模式的键设置特定值
url
,则 grunt-clean-console 成功工作:phantomjs: opening page output/index.html phantomjs: Checking errors after sleeping for 5000ms ok output/index.html phantomjs process exited with code 0 Done.
3.1。重现步骤
我在控制台中运行:
grunt clean-console --verbose
4.没有帮助
4.1。通配符
Gruntfile.coffee
:module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-clean-console' grunt.initConfig 'clean-console': all: options: url: 'output/**/*.html' return
输出:
phantomjs: opening page http://output/**/*.html phantomjs: Unable to load resource (#1URL:http://output/**/*.html) phantomjs: phantomjs://code/runner.js:30 in onResourceError Error code: 3. Description: Host output not found phantomjs://code/runner.js:31 in onResourceError phantomjs: loading page http://output/**/*.html status fail phantomjs://code/runner.js:50 phantomjs process exited with code 1 url output/**/*.html has 1 error(s) >> one of the urls failed clean-console check Warning: Task "clean-console:all" failed. Use --force to continue. Aborted due to warnings.
4.2. 动态构建对象
Gruntfile.coffee
(例子):module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-clean-console' grunt.initConfig 'clean-console': all: options: url: files: [ expand: true cwd: "output/" src: ['**/*.html'] dest: "output/" ] return
输出:
File: [no files] Options: urls=[], timeout=5, url=["output/**/*.html"] Fatal error: missing url
4.3. 模板
Gruntfile.coffee
:module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-clean-console' grunt.initConfig 'clean-console': all: options: url: '<%= kiratemplate %>' kiratemplate: ['output/**/*.html'], return
输出:
phantomjs: opening page http://output/**/*.html phantomjs: Unable to load resource (#1URL:http://output/**/*.html) phantomjs: phantomjs://code/runner.js:30 in onResourceError Error code: 3. Description: Host output not found phantomjs://code/runner.js:31 in onResourceError loading page http://output/**/*.html status fail phantomjs://code/runner.js:50 phantomjs process exited with code 1 url output/**/*.html has 1 error(s) >> one of the urls failed clean-console check Warning: Task "clean-console:all" failed. Use --force to continue. Aborted due to warnings.