2016-09-21 98 views
1

使用polymer init您可以創建元素項目並使用polymer serve您可以提供組件頁面(顯示文檔和演示)。聚合物CLI:構建組件頁面

要提供它,Polymer CLI會執行一些路徑重新映射,因爲導入標記與項目結構不匹配。從文檔:

當您運行聚合物發球局,在bower_components所有元素都是 重新映射到似乎是在同級相對於我的-EL目錄。 當前元素由名稱的/ components/bower 的組成路徑提供,其中bower名稱是元素項目的 bower.json文件中的名稱字段。

什麼應該是適當的方式建立組件頁面,以便它可以通過另一個Web服務器提供服務?

我應該移動這些文件,以便它們與引用匹配,還是有更好的方法?

+0

你摸不着頭腦?我有一個類似的問題(不同的本地目錄結構,缺少我需要的「bower_components」)。 – montrealist

+1

@montrealist nope – pomber

+0

@montrealist查看答案。也許你可以根據你的需要定製[腳本](https://github.com/Polymer/tools/blob/master/bin/gp.sh) – pomber

回答

2

有一個工具可以將組件頁面部署到github頁面。
docs

在下面的命令,替換爲您GitHub上的用戶名,並與 您的GitHub庫名稱。

# git clone the Polymer tools repository somewhere outside of your 
# element project 
git clone git://github.com/Polymer/tools.git 

# Create a temporary directory for publishing your element and cd into it 
mkdir temp && cd temp 

# Run the gp.sh script. This will allow you to push a demo-friendly 
# version of your page and its dependencies to a GitHub pages branch 
# of your repository (gh-pages). Below, we pass in a GitHub username 
# and the repo name for our element 
../tools/bin/gp.sh <username> <test-element> 

# Finally, clean-up your temporary directory as you no longer require it 
cd .. 
rm -rf temp 

這將創建一個新的GH-頁面分支(或克隆和清除​​當前 一個),然後把你的元素的共享版本吧。要查看 新發布的文件,指向瀏覽器:

http://<username>.github.io/<test-element>/