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.
 
 
 
 

70 lines
1.7 KiB

import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import {svgBuilder} from './src/config/svgBuilder'
import requireTransform from 'vite-plugin-require-transform'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueJsx(),
requireTransform({
fileRegex: /.js$|.vue$/
}),
svgBuilder('./src/assets/svg/'),//提取导入svg文件
],
resolve:{
alias:{
"@":path.resolve(__dirname,'src'),
}
},
build:{
outDir:"dist",
assetsDir:"static",
cssCodeSplit:true, // 拆分css代码
brotliSize: false, // 压缩代码
rollupOptions:{
input:{ // 多项目打包
index: path.resolve(__dirname, 'index.html'),
},
// 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,
host:"0.0.0.0",
strictPort:false, //端口被占用是不会退出,换新端口
open:true, // 自动打开页面
proxy:{
'/api':{
target:"",
changeOrigin:true,
ws:false,
rewrite: path=>path.replace(/^\/api/,'')
}
},
},
pluginOptions:{
'style-resources-loader':{
preProcessor: 'less',
patterns:[
// 全局less文件
path.resolve(__dirname, 'assets/style/index.less')
]
}
}
})