vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.43k stars 6.17k forks source link

Nested static routes are failing to render or redirect #160

Closed JessicaSachs closed 4 years ago

JessicaSachs commented 4 years ago

Describe the bug

Nested static routes are no longer rendering or redirecting properly

If this is now the desired behavior, it is also failing to execute the redirect properly.

  1. When the user navigates to /subdir/index.html, the page served is /index.html
  2. The relative imports in /index.html are executed relative to the originally requested file... e.g. /subdir/main.js is requested instead of /main.js

Reproduction

https://github.com/JessicaSachs/vite-component-test-starter/tree/repro/vite-0.15.3

npm i
npm run dev
open http://localhost:3000/test/index.html

System Info

Logs (Optional if provided reproduction)

vite v0.15.3
  vite:resolve (node_module entry) vue -> vue/dist/vue.runtime.esm-bundler.js +0ms
[vite] Optimizable dependencies detected.
Pre-bundling them to speed up dev server page load...
  (this will be run only when your dependencies have changed)
Optimized modules:
vue

  Dev server running at:
  > Local:    http://localhost:3000/
  > Network:  http://172.16.10.52:3000/

  vite:server server ready in 874ms. +0ms
redirecting / to /index.html
  vite:hmr         /index.html imports /main.js +0ms
  vite:rewrite /index.html: no imports found. +0ms
not redirecting /main.js (has file extension)
  vite:rewrite /main.js: rewriting +167ms
  vite:rewrite     "vue" --> "/@modules/vue" +0ms
  vite:hmr         /main.js imports /@modules/vue +168ms
  vite:rewrite     "./App.vue" --> "/App.vue" +1ms
  vite:hmr         /main.js imports /App.vue +1ms
  vite:hmr ws client connected +445ms
  vite:resolve (optimized) vue -> node_modules/.vite_opt_cache/vue.js +0ms
  vite:sfc /Users/jess/projects/vite-component-test-starter/App.vue parsed in 5ms. +0ms
  vite:rewrite /App.vue: rewriting +454ms
  vite:rewrite     "vite/hmr" --> "/vite/hmr" +0ms
  vite:rewrite /@modules/vue: no imports found. +5ms
  vite:sfc /Users/jess/projects/vite-component-test-starter/App.vue parse cache hit +7ms
  vite:sfc /App.vue template compiled in 15ms. +15ms
  vite:rewrite (skipped) /App.vue?type=template +16ms
  vite:sfc /Users/jess/projects/vite-component-test-starter/App.vue parse cache hit +5ms
  vite:sfc /App.vue style compiled in 59ms +59ms
  vite:rewrite (skipped) /App.vue?type=style&index=0 +65ms
redirecting /test/index.html to /index.html
  vite:rewrite /index.html: serving from cache +5s
not redirecting /test/main.js (has file extension)
  vite:rewrite (skipped) /test/main.js +20ms
  vite:hmr ws client connected +5s
JessicaSachs commented 4 years ago

Nice. Just verified this works in the latest (0.15.5) and upgraded Vite Component Test Starter to use it