- Fix 'Failed to resolve import @/stores/function' error
- Add '@' alias pointing to './src' directory
- Enable cleaner import paths in Vue components
Before:
import { useFunctionStore } from '@/stores/function' // Error!
After:
import { useFunctionStore } from '@/stores/function' // Works!
Changes:
- Import 'path' module
- Configure resolve.alias in vite.config.js
- Add fix documentation
23 lines
451 B
JavaScript
23 lines
451 B
JavaScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import path from 'path'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [vue()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src')
|
|
}
|
|
},
|
|
server: {
|
|
host: '0.0.0.0', // 允许局域网访问
|
|
port: 5173,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8000',
|
|
changeOrigin: true
|
|
}
|
|
}
|
|
}
|
|
}) |