import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
base: './',//打包后的静态资源路径修改
plugins: [
vue(),
styleImport({
libs: [
{
libraryName: 'element-plus',
resolveStyle: (name) => {
name = name.slice(3) // 这里有个彩蛋,官网居然是用splice的,没错用的是数组方法。
return `element-plus/packages/theme-chalk/src/${name}.scss`
},
resolveComponent: (name) => {
return `element-plus/lib/${name}`
}
}
]
})
],
resolve: {
alias: {
'@': resolve(__dirname, './src')//绝对路径@的修改
}
},
server: { //代理地址
proxy: {
'/start': {
target:'http://10.2.249.243:9991',
ws: true,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/start/, '')
},
}
},
build: { //打包构建
rollupOptions: {
output: {
assetFileNames: 'css/[name].[hash].css',
chunkFileNames: 'js/[name].[hash].js',
entryFileNames: 'js/[name].[hash].js'
}
}
}
})
vue3 vite.config.ts 配置
最新推荐文章于 2024-03-14 20:06:59 发布