将聚合物应用程序提供给/不在根目录的路径

Chr*_*oll 6 polymer

因此,我想要使用新的Polymer应用程序做的第一件事是部署到现有网站上的目录.似乎唯一有用的就是部署到root /.

我们来看看Shop的例子.我做:

  1. polymer init 并选择商店
  2. polymer build
  3. Robocopy.exe .\build\bundled\ C:\inetpub\wwwroot\p\ /MIR
  4. start http://localhost/p/

你看我在Windows上.我认为使用IIS是无关紧要的,因为我只依靠服务器来提供静态内容.

我需要在商店模板中编辑什么才能使其在网址上运行http://localhost/p/

Sas*_*sov 6

聚合物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>
Run Code Online (Sandbox Code Playgroud)

如果在这个index.html文件中你注释掉base标签并设置window.Polymer rootPath就像'/0/polymer-test/build/es5-bundled/'你可以在应用程序中导航http://localhost/0/polymer-test/build/es5-bundled/