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.
64 lines
1.9 KiB
64 lines
1.9 KiB
import { fileURLToPath, URL } from 'node:url'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue2'
|
|
import vueJsx from '@vitejs/plugin-vue2-jsx'
|
|
import inject from '@rollup/plugin-inject'
|
|
import { chunkSplitPlugin } from 'vite-plugin-chunk-split'
|
|
|
|
const resolve = (dir) => {
|
|
return fileURLToPath(new URL(dir, import.meta.url))
|
|
}
|
|
|
|
export default defineConfig(({ command, mode }) => {
|
|
// 根据当前工作目录中的 `mode` 加载 .env 文件
|
|
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
return {
|
|
// vite 配置
|
|
build: {
|
|
outDir: 'dist',
|
|
assetsDir: 'static',
|
|
rollupOptions: {
|
|
output: {
|
|
entryFileNames: `static/[name].[hash].js`,
|
|
chunkFileNames: `static/[name].[hash].js`,
|
|
assetFileNames: `static/[name].[hash].[ext]`
|
|
}
|
|
}
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 5050,
|
|
proxy: {
|
|
'/imurs': {
|
|
target: env.VITE_HOST_NAME,
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/imurs/, '')
|
|
},
|
|
}
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'vue$': 'vue/dist/vue.esm.js',
|
|
'@': resolve('src'),
|
|
'assets': resolve('src/assets'),
|
|
'agora': resolve('src/agora'),
|
|
'public': resolve('src/components/system/public'),
|
|
}
|
|
},
|
|
plugins: [vue(), vueJsx(), chunkSplitPlugin({
|
|
// customSplitting: {
|
|
// 'vue-vendor': ['vue', 'vuex', 'vue-router', 'vue-template-compiler', /src\/vue-config/]
|
|
// }
|
|
}), inject({
|
|
modules: {
|
|
AGORA_APP_ID: ['agora/agoraConfig', 'AGORA_APP_ID'],
|
|
RtcClient: ['agora/rtcClient', 'default'],
|
|
StorageChannel: ['public/storageSignaling', 'default'],
|
|
}
|
|
})],
|
|
// define: {
|
|
// __APP_ENV__: env.APP_ENV,
|
|
// }
|
|
}
|
|
})
|
|
|