73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
import uni from '@dcloudio/vite-plugin-uni';
|
|
import { loadEnv } from 'vite';
|
|
import viteCompression from 'vite-plugin-compression';
|
|
import path from 'path';
|
|
import uniReadPagesV3Plugin from './src/sheep/router/utils/uni-read-pages-v3';
|
|
// import mpliveMainfestPlugin from './src/sheep/libs/mplive-manifest-plugin';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default async (command: 'build' | 'serve', mode: string) => {
|
|
const env = loadEnv(mode, __dirname, 'SHOPRO_');
|
|
const { default: Unocss } = await import('unocss/vite');
|
|
|
|
return {
|
|
envPrefix: 'SHOPRO_',
|
|
plugins: [
|
|
uni(),
|
|
Unocss(),
|
|
viteCompression({
|
|
verbose: false,
|
|
}),
|
|
uniReadPagesV3Plugin({
|
|
pagesJsonDir: path.resolve(__dirname, './src/pages.json'),
|
|
includes: ['path', 'aliasPath', 'name', 'meta'],
|
|
}),
|
|
// mpliveMainfestPlugin(env.SHOPRO_MPLIVE_ON),
|
|
],
|
|
// esbuild: {
|
|
// target: 'es2015',
|
|
// supported: {
|
|
// 'optional-chain': false,
|
|
// 'nullish-coalescing': false,
|
|
// },
|
|
// },
|
|
// build: {
|
|
// target: 'es2015',
|
|
// },
|
|
server: {
|
|
host: true,
|
|
hmr: {
|
|
overlay: true,
|
|
},
|
|
proxy: {
|
|
// 应用相关api
|
|
'/app-api': {
|
|
target: env.SHOPRO_DEV_BASE_URL,
|
|
changeOrigin: true,
|
|
},
|
|
// 聊天相关api
|
|
'/api': {
|
|
target: 'http://im-platform.htysapp.com',
|
|
// target: 'http://127.0.0.1:8888',
|
|
changeOrigin: true,
|
|
rewrite: (path: string) => path.replace(/^\/api/, ''),
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
// additionalData: `@use "@/main.scss" as *;`,
|
|
api: 'modern-compiler',
|
|
// silenceDeprecations: ['legacy-js-api'],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|