2017-05-05 1 views
1

Node -v 7.7.3をサポートするようにアプリケーションを更新しようとしています。しかし、私は以下のとおり面倒なタスクdom_mungerを実行していたとき:ノード7.7.3でDom_mungerの問題 - パスは文字列でなければなりません。

dom_munger:{ 
    read: { 
    options: { 
     read:[ 
     {selector:'script[data-concat!="false"]',attribute:'src',writeto:'appjs', isPath: true}, 
     {selector:'link[rel="stylesheet"][data-concat!="false"]',attribute:'href',writeto:'appcss'} 
     ] 
    }, 
    src: 'app/index.html' 
    } 
} 

私はエラーが表示さ:面倒なタスクの上または良いがあるかもしれない場合は書き換えるための方法がある場合、私は疑問に思う

Warning: Path must be a string. Received [ 'app/index.html' ] Use --force to continue. 

をdom_mungerの代わり。どんな助けもありがとう。 grunt-dom-munger Githubのパー

答えて

0

When isPath is true, the extracted values are assumed to be file references and their path is made relative to the Gruntfile.js rather than the file they're read from.

isPathプロパティを削除、またはindex.htmlファイルへのごGruntfileからのパスに一致するように、それを変更してください。

+0

ありがとうございます!しかし、これはGruntとIndexが同じフォルダ構造にある場合にのみ有効です。私の構造は次のようになります。 - /アプリ -index.html - そして属性なしをgruntfile.js「isPath」Gruntfileが場所ですとdom_mungerが同じディレクトリにjsのファイルを探します。 – sandrasvensson

+0

@sandrasvenssonしかし、あなたは 'isPath'プロパティを削除しようとしましたか?それは[この類似の問題](https://github.com/cgross/grunt-dom-munger/issues/42)を解決するように思われた。 –

0

ありがとう!しかし、これはGruntとIndexが同じフォルダ構造にある場合にのみ有効です。私の構造は次のようになります。

- /app 
    -index.html 
- gruntfile.js 

そして属性を持たない「isPath」Gruntfileが場所ですとdom_mungerが同じディレクトリにjsのファイルを探します。

0

isPath:trueを削除し、src属性のパスが読み込み先のファイルではなく、Gruntfile.jsを基準にしていることを確認してください。

ニーズがパスに置き換え作る場合:

dom_munger: { 
    replacePath: { 
    options: { 
     callback: function($, file){ 
     var scripts = $('script[data-concat!="false"]'); 
     // NOTE: path is made relative to the Gruntfile.js rather than the file they're read from 
     for(var i=0, s, il=scripts.length; i<il; i++){ 
      s = scripts[i]; 
      if(s.attribs.src){ 
      s.attribs.src = s.attribs.src.replace('../', ''); 
      } 
     } 
     } 
    }, 
    src: 'temp/index.html' 
    }, 
    read: { 
    options: { 
     read: [ 
     {selector:'script[data-concat!="false"]',attribute:'src',writeto:'appjs'}, 
     {selector:'link[rel="stylesheet"][data-concat!="false"]',attribute:'href',writeto:'appcss'} 
     ] 
    }, 
    src: 'temp/index.html' 
    } 
} 
関連する問題