【问题标题】:Polymer CLI: build component pagePolymer CLI:构建组件页面
【发布时间】:2016-09-21 17:31:39
【问题描述】:

使用polymer init 您可以创建一个元素项目,使用polymer serve 您可以提供组件页面(显示文档和演示)。

为了服务它,Polymer CLI 会进行一些路径重新映射,因为导入标签与项目结构不匹配。来自文档:

当您运行聚合物服务时,bower_components 中的所有元素都是 重新映射以显示在相对于 my-el 的同级目录中。这 当前元素是从 /components/bower 的组成路径提供的 name,其中 bower name 是元素项目中的名称字段 bower.json 文件。

构建组件页面的合适方法应该是什么,以便它可以由另一个 Web 服务器提供服务?

我应该移动文件以使它们与引用匹配还是有更好的方法?

【问题讨论】:

  • 你发现了吗?我有一个类似的问题(不同的本地目录结构,缺少我需要适应的 bower_components)。
  • @montrealist nope
  • @montrealist 检查答案。也许您可以根据需要自定义the script

标签: polymer polymer-1.0 web-component polymer-cli


【解决方案1】:

有一个将组件页面部署到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-pages 分支(或克隆并清除当前 一)然后将您的元素的可共享版本推送到它。看到你的 新发布的文档,将浏览器指向:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-13
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 2016-11-19
    • 1970-01-01
    • 1970-01-01
    • 2018-03-18
    相关资源
    最近更新 更多