gulp-file-includeを使用してHTMLテンプレート内のCSSおよびJavaScriptファイルにリンクするにはどうすればよいでしょうか?gulp-file-includeを使用したHTMLテンプレートからのファイルへの相対パス
例:
index.htmlを
@@include('templates/doc-begin.html')
<h1>Welcome</h1>
<p>Hello!</p>
@@include('templates/doc-end.html')
サポート/ index.htmlを
@@include('templates/doc-begin.html')
<h1>Support</h1>
<p>RTFM</p>
@@include('templates/doc-end.html')
テンプレート/ DOC-begin.html
<!doctype html>
<html lang=en>
<head>
<title>Website</title>
<link rel=stylesheet href=?????/style.css>
</head>
<body>
2つのindex.html
ファイルは異なるフォルダレベルにあるため、link
タグのスタイルシートへの相対パスはハードコードできません(絶対パスには問題があり、この場合は望ましくありません)。
基本的には最初のlink
タグのようなものである必要があります:
<link rel=stylesheet href=style.css>
など二何か:
<link rel=stylesheet href=../style.css>
を行うには一気-ファイルが含まで便利な方法がありますこの?
注:
私は現在、私は"."
、".."
、または各@@include
呼び出しに"../.."
として変数を渡すの回避策を持っているが、それは面倒と脆いです。
機能のリクエスト: https://github.com/coderhaoxin/gulp-file-include/issues/115 –