如何使用Polymer CLI构建Polymer 2.x项目? [英] How do I build a Polymer 2.x project with Polymer CLI?

查看:87
本文介绍了如何使用Polymer CLI构建Polymer 2.x项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以指出我使用Polymer CLI的Polymer 2和polymer-build的教程吗?当我在polymer-starter-kit中使用任何示例并使用polymer serve时,它都可以正常工作;但是当我使用polymer build并提供bundledunbundled目录时,会出现404错误.我什至已经更新到polymer-cli的最新Alpha版本.

Can anyone point me to a tutorial that uses Polymer 2 and polymer-build from Polymer CLI? When I use any example in the polymer-starter-kit and use polymer serve, it works fine; but when I use polymer build and serve the bundled or unbundled directory, I get 404 errors. I have even updated to the newest alpha version of polymer-cli.

此外,使用 https://github.com/tony19/generator-polymer-init-2-x-app 生成器具有相同的问题.

Also, using https://github.com/tony19/generator-polymer-init-2-x-app generators have the same problem.

推荐答案

我还花了一些时间来解决这个问题.请使用polymer-cli@next而不是polymer-cli

I also spent quit a bit of time to figure this one out. Please use the polymer-cli@next instead of polymer-cli

普通polymer-cli似乎没有最新的版本和优化来支持Polymer 2.0#Preview相关功能.

Plain polymer-cli doesn't seem to have the latest build and optimizations to support Polymer 2.0#Preview related functionality.

您可以安装polymer-cli@next.在Ubuntu中,您只需使用npm install -g polymer-cli@next

You can install polymer-cli@next. In Ubuntu, you can simply use npm install -g polymer-cli@next

然后,通过polymer build生成的应用程序的捆绑和非捆绑版本就可以正常工作.

Then on, the bundled and unbundled versions of the application generated through polymer build would just works fine.

修改: 您可以在 https://github.com上找到我的示例Polymer2.0#Preview代码版本. /phani1kumar/phani1kumar.github.io 分支是"devmaster".

You can find my sample Polymer2.0#Preview version of the code at https://github.com/phani1kumar/phani1kumar.github.io branch is "devmaster".

sw-precache-config.js是初始渲染块.这将加载主页需要的所有资源,以使该应用程序可脱机使用. src/lazy-resources.html加载下一条路线的资源.

the sw-precache-config.js is initial render-blocking. This will load all the resources that the main page needs to make the app available for offline use. src/lazy-resources.html loads resources for the next routes.

您需要根据布局和主页的以下3个文件获得正确的配置: sw-precache-config.js, polymer.json, src/lazy-resources.html.这是Polymer团队在shop应用程序中遵循的一种做法,您可以选择其他机制进行延迟加载.延迟加载的底线是在Polymer.RenderStatus.afterNextRender之后加载资源.

You would need to get a proper configuration based on your layout and main page in the following 3 files: sw-precache-config.js, polymer.json, src/lazy-resources.html. This is a practice followed in the shop app from Polymer team, you may opt to a different mechanism for lazy loading. The bottom-line for lazy loading is to load the resources after Polymer.RenderStatus.afterNextRender.

您可能还会发现以下有趣的文章:

You may also find the following article interesting: https://medium.com/@marcushellberg/how-i-sped-up-the-initial-render-of-my-polymer-app-by-86-eeff648a3dc0#.pi2iucwzi

这篇关于如何使用Polymer CLI构建Polymer 2.x项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆