【发布时间】:2019-06-20 16:25:20
【问题描述】:
1。总结
我无法设置grunt-clean-console 插件,它适用于我所有的.html 文件。
2。详情
grunt-clean-console 检查 .html 文件的浏览器控制台错误。
我想检查我网站上所有.html 文件的浏览器控制台错误。 In official descripition 我读到,插件如何为 url 键的特定值工作。我的网站上有很多页面;我不想单独添加每个 .html 文件。但我找不到,我如何使用模式。
我发现,我可以将模式用于内置 Grunt cwd、src、dest 键。但是我如何将 glob(或其他)模式用于自定义键作为这个插件的 url?
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.
【问题讨论】:
标签: gruntjs glob gruntfile grunt-plugins