vite: 404 after configuring alias

Describe the bug

Reproduction

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

 npmPackages:
    @vitejs/plugin-vue: ^1.2.1 => 1.2.1 
    @vue/compiler-sfc: ^3.0.5 => 3.0.11 
    typescript: ^4.1.3 => 4.2.4 
    vite: ^2.1.5 => 2.2.1 
    vite-plugin-rewrite-all: ^0.1.2 => 0.1.2 
    vue: ^3.0.5 => 3.0.11 
    vue-router: ^4.0.6 => 4.0.6 
    vue-tsc: ^0.0.24 => 0.0.24 

Used package manager: npm

cofig.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path'
import pluginRewriteAll from 'vite-plugin-rewrite-all';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),],
  // resolve: {
  //   alias: {
  //     '/lib/': resolve(__dirname,'lib'),
  //     '/module/': resolve(__dirname,'scr/module'),
  //   }
  // },
  assetsInclude:resolve(__dirname,'lib')
})

Logs

  vite:spa-fallback Not rewriting GET /libtiles/16/12320/2565.png because the path includes a dot (.) character. +17ms
  vite:time 5ms   /index.html +19ms
  vite:spa-fallback Not rewriting GET /libtiles/16/12320/2567.png because the path includes a dot (.) character. +11ms
  vite:time 3ms   /index.html +10ms
  vite:spa-fallback Not rewriting GET /libtiles/16/12322/2566.png because the path includes a dot (.) character. +5ms
  vite:time 2ms   /index.html +4ms
  vite:spa-fallback Not rewriting GET /libtiles/16/12319/2565.png because the path includes a dot (.) character. +4ms

remove alias config

  vite:time 3ms   /lib/tiles/16/12326/2565.png +1ms
  vite:time 2ms   /lib/tiles/16/12323/2569.png +872ms
  vite:time 1ms   /lib/tiles/16/12322/2569.png +0ms
  vite:time 2ms   /lib/tiles/16/12324/2569.png +3ms
  vite:time 2ms   /lib/tiles/16/12321/2569.png +1ms
  vite:time 3ms   /lib/tiles/16/12325/2569.png +7ms
  vite:time 3ms   /lib/tiles/16/12320/2569.png +1ms
  vite:time 3ms   /lib/tiles/16/12326/2569.png +0ms
  vite:time 1ms   /lib/tiles/16/12319/2569.png +69ms

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

http://localhost:3000/lib/tiles/16/12320/2566.png” 404

Document tree structure
.
├── README.md
├── index.html
├── lib
│   ├── AreaRestriction_min.js
│   ├── CurveLine.min.js
│   ├── images
│   │   ├── .....
│   ├── js解释.txt
│   ├── map3.0.js
│   ├── map3.0_init.js
│   ├── modules
│   │   ├── vmlcontext_41oars.js
│   │   └── 全部模块.txt
│   └── tiles
│       ├── 14
│           ├── 3078
│           │   ├── 640.png
│           │   ├── 641.png
│           │   ├── 642.png
│           │   ├── 643.png
│           │   └── 644.png
│           ├── 3079
│           │   ├── 640.png
│           │   ├── 641.png
│           │   ├── 642.png
│           │   ├── 643.png
│           │   └── 644.png
│           ├── 3080
│           │   ├── 642.png
│           │   ├── 643.png
│           │   └── 644.png
│           ├── 3081
│           │   ├── 640.png
│           │   ├── 641.png
│           │   ├── 642.png
│           │   └── 644.png
│           ├── 3082
│           │   ├── 640.png
│           │   ├── 641.png
│           │   ├── 642.png
│           │   ├── 643.png
│           │   └── 644.png
│           └── 3083
│               ├── 640.png
│               ├── 641.png
│               ├── 642.png
│               └── 644.png
├── node_modules
│    └──..... 
├── package-lock.json
├── package.json
├── public
│   └── favicon.ico
├── src
│   ├── App.vue
│   ├── assets
│   │   └── logo.png
│   ├── components
│   │   └── HelloWorld.vue
│   ├── index.css
│   ├── main.js
│   ├── main.js.map
│   ├── main.ts
│   ├── module
│   │   ├── ComplexCustomOverlay.js
│   │   ├── ComplexCustomOverlay.js.map
│   │   └── ComplexCustomOverlay.ts
│   ├── router
│   │   ├── index.js
│   │   ├── index.js.map
│   │   └── index.ts
│   └── shims-vue.d.ts
├── tsconfig.json
└── vite.config.ts

709 directories, 21053 files

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

The issue is that v1 never got to a stable release and most users of Vite haven’t used that v1. By giving this a higher position you are lowering other topics that may help more people. We could add a note maybe at the getting started guide, but I don’t know if that would help. I think the best is to use the search functionality in the docs that would have guided you to the migration guide if you searched for “alias”

The command should be npm init @vitejs/app