You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

3 years ago
import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve:{
alias:{
"@":path.resolve(__dirname,'src'),
}
},
build:{
outDir:"dist",
assetsDir:"static",
cssCodeSplit:true, // 拆分css代码
rollupOptions:{
input:{ // 多项目打包
index: path.resolve(__dirname, 'index.html')
// index: path.resolve(__dirname, 'src/index.js')
},
// external:['vue'], // 控制插件不编译
output: {
entryFileNames: `static/[name].[hash].js`,
chunkFileNames: `static/[name].[hash].js`,
assetFileNames: e=>{
console.log('name=',e.anme)
console.log('type=',e.type)
return 'assets/[name].[hash].[ext]'
},
},
}
},
optimizeDeps:{
include:[] // 依赖预编译
},
server:{
port:8085,
strictPort:false, //端口被占用是不会退出,换新端口
open:true, // 自动打开页面
proxy:{
'/api':{
target:"",
changeOrigin:true,
ws:false,
rewrite: path=>path.replace(/^\/api/,'')
}
},
}
})