vite中使用别名


背景: vue3+vite

 

vite.config.js

 1 // import { defineConfig } from 'vite'
 2 import vue from '@vitejs/plugin-vue'
 3 import styleImport from 'vite-plugin-style-import'
 4 const path = require('path')
 5 
 6 export default {
 7   plugins: [
 8     vue(),
 9     styleImport({
10       libs: [
11         {
12           libraryName: 'vant',
13           esModule: true,
14           resolveStyle: name => `vant/es/${name}/style/index`
15         }
16       ]
17     })
18   ],
19   resolve: {
20     alias: {
21       '@': path.resolve('src')
22     }
23   }
24 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM