56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import path from 'path'
|
|
|
|
console.log(
|
|
['NODE', 'NODE_ENV', 'npm_execpath', 'OS'].map(key => (process.env[key]))
|
|
)
|
|
const devServer = {
|
|
default: 'http://localhost:3001',
|
|
test: 'http://43.136.175.109:50001'
|
|
}
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const devServerTarget = devServer[mode] || devServer.default
|
|
console.log(`server run in ${mode} target is ${devServerTarget}`)
|
|
return {
|
|
plugins: [vue()],
|
|
build: {
|
|
// 小于10kb直接base64
|
|
assetsInlineLimit: 10240,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
// console.log('chunk id',id)
|
|
// if (id.includes('ant-design')) {
|
|
// return 'ui-libs'
|
|
// }
|
|
// if (id.includes('vue')) {
|
|
// if (id.includes('node_modules')) {
|
|
// return 'vue'
|
|
// }
|
|
// return id.toString().split('node_modules/')[1].split('/')[0].toString();
|
|
// }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
base: './',
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src')
|
|
}
|
|
},
|
|
server: {
|
|
port:10086,
|
|
proxy: {
|
|
'/api': {
|
|
target: devServerTarget,
|
|
changeOrigin: true,
|
|
// rewrite: path => path.replace(/^\/api/, '')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|