Serve: Support serving from virtual directory

Created on 16 Jan 2019  路  2Comments  路  Source: vercel/serve

I have an application that has to be mounted from a virtual directory with a given name. Today I solve this by manually creating that directory after build, and moving all build artifacts into it (example: make dir blog, and move build/* into it, then serve from .). It would be great if I could configure serve to serve a folder from localhost:8080/virtual/path.

Most helpful comment

I found that the following works:

  "rewrites": [
    {
      "source": "virtual/path/static/:gen/:type/:name",
      "destination": "/static/:gen/:type/:name"
    }
  ]

However, I have to put a bunch of rewrites to handle all cases, so it's a bit brittle. I could not get the following rewrite to work: virtual/path/static/:path* => /static/:path.

All 2 comments

In need of exactly this! I have a homepage path set in my package.json and serving my CRA build locally requires me to manually create the folder structure 馃

I found that the following works:

  "rewrites": [
    {
      "source": "virtual/path/static/:gen/:type/:name",
      "destination": "/static/:gen/:type/:name"
    }
  ]

However, I have to put a bunch of rewrites to handle all cases, so it's a bit brittle. I could not get the following rewrite to work: virtual/path/static/:path* => /static/:path.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  7Comments

nikitamendelbaum picture nikitamendelbaum  路  6Comments

nermin99 picture nermin99  路  3Comments

xiyuyizhi picture xiyuyizhi  路  5Comments

Timer picture Timer  路  5Comments