Vite @ alias path All In One
error
@
alias path
solution
// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
const path = require('path')
// https://vitejs.dev/config/
export default defineConfig({
resolve:{
alias:{
'@' : path.resolve(__dirname, './src')
},
},
plugins: [vue()]
})
https://vueschool.io/articles/vuejs-tutorials/import-aliases-in-vite/
https://stackoverflow.com/questions/66043612/vue3-vite-project-alias-src-to-not-working
https://vitejs.dev/config/#resolve-alias
demo
<template>
<!-- <>react fragment</> -->
<!-- <template>vue fragment</template> -->
<template v-if="true">
<div>{{store.msg}}</div>
</template>
<template v-if="true">
<div>{{store.getMsg}}</div>
<!-- <pre>{{jsonString}}</pre> -->
<pre>❓ {{store.msg}}</pre>
<span v-pre>{{ this will not be compiled }}❓ {{store.msg}}</span>
<button @click="updateMsg">Pinia