所以我想对一个新的 Polymer 应用程序做的第一件事是部署到现有网站上的目录。唯一似乎有效的是部署到 root /
.
让我们以 Shop 为例。我愿意:
polymer init
并选择店铺polymer build
Robocopy.exe .\build\bundled\ C:\inetpub\wwwroot\p\ /MIR
start http://localhost/p/
你看我在 Windows 上。我认为使用 IIS 无关紧要,因为我依赖服务器只是为了提供静态内容。
我需要在商店模板中编辑什么才能使其在 url
http://localhost/p/
上工作?
最佳答案
polymer cli 创建的应用程序假设从根级别“/”提供服务。在生成的项目中 index.html
你会发现两条评论
<!--
The `<base>` tag below is present to support two advanced deployment options:
1) Differential serving. 2) Serving from a non-root path.
Instead of manually editing the `<base>` tag yourself, you should generally either:
a) Add a `basePath` property to the build configuration in your `polymer.json`.
b) Use the `--base-path` command-line option for `polymer build`.
Note: If you intend to serve from a non-root path, see [polymer-root-path] below.
-->
<base href="/">
<!-- ... -->
<script>
/**
* [polymer-root-path]
*
* By default, we set `Polymer.rootPath` to the server root path (`/`).
* Leave this line unchanged if you intend to serve your app from the root
* path (e.g., with URLs like `my.domain/` and `my.domain/view1`).
*
* If you intend to serve your app from a non-root path (e.g., with URLs
* like `my.domain/my-app/` and `my.domain/my-app/view1`), edit this line
* to indicate the path from which you'll be serving, including leading
* and trailing slashes (e.g., `/my-app/`).
*/
window.Polymer = {rootPath: '/'};
// ...
</script>
如果在此
index.html
您注释掉的文件 base
标记并设置 window.Polymer rootPath
类似于 '/0/polymer-test/build/es5-bundled/'
您将能够在 http://localhost/0/polymer-test/build/es5-bundled/
上的应用程序中导航
关于polymer - 将 Polymer 应用程序提供给不在根目录下的/path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42090070/