1

1. まとめ

すべてのファイルで機能するgrunt-clean-consoleプラグインを設定できません。.html


2. 詳細

grunt-clean-console ファイルのブラウザ コンソール エラーをチェックし.htmlます。

.htmlサイトのすべてのファイルのブラウザ コンソール エラーを確認したい。私が読んだ公式urlの説明では、キーの特定の値に対してプラグインがどのように機能するか。私のサイトには多くのページがあります。.html各ファイルを個別に追加したくありません。しかし、パターンを使用する方法が見つかりません。

cwd組み込みの Grunt 、srcdestキーのパターンを使用できることがわかりました。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.
    
4

1 に答える 1