|
@@ -1,5 +1,5 @@
|
|
|
// vite.config.ts
|
|
// vite.config.ts
|
|
|
-import { defineConfig } from 'vite'
|
|
|
|
|
|
|
+import { defineConfig, loadEnv } from 'vite'
|
|
|
import UniKuRoot from '@uni-ku/root'
|
|
import UniKuRoot from '@uni-ku/root'
|
|
|
import uni from '@dcloudio/vite-plugin-uni'
|
|
import uni from '@dcloudio/vite-plugin-uni'
|
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
@@ -7,8 +7,10 @@ import Components from '@uni-helper/vite-plugin-uni-components'
|
|
|
import { WotResolver } from './resolvers/wot-ui-resolver'
|
|
import { WotResolver } from './resolvers/wot-ui-resolver'
|
|
|
import path from 'path'
|
|
import path from 'path'
|
|
|
|
|
|
|
|
-export default defineConfig(async () => {
|
|
|
|
|
|
|
+export default defineConfig(async ({ mode }) => {
|
|
|
const { default: tsconfigPaths } = await import('vite-tsconfig-paths')
|
|
const { default: tsconfigPaths } = await import('vite-tsconfig-paths')
|
|
|
|
|
+ const { VITE_BASE_API } = loadEnv(mode, process.cwd())
|
|
|
|
|
+ const isH5 = process.env.UNI_PLATFORM === 'h5'
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
plugins: [
|
|
plugins: [
|
|
@@ -29,5 +31,36 @@ export default defineConfig(async () => {
|
|
|
'@': path.resolve(__dirname, 'src'),
|
|
'@': path.resolve(__dirname, 'src'),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ ...(isH5
|
|
|
|
|
+ ? {
|
|
|
|
|
+ build: {
|
|
|
|
|
+ rollupOptions: {
|
|
|
|
|
+ output: {
|
|
|
|
|
+ entryFileNames: 'assets/[name]-[hash].js',
|
|
|
|
|
+ chunkFileNames: 'assets/[name]-[hash].js',
|
|
|
|
|
+ assetFileNames: 'assets/[name]-[hash][extname]',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+ : {}),
|
|
|
|
|
+
|
|
|
|
|
+ server: {
|
|
|
|
|
+ proxy: {
|
|
|
|
|
+ '/admin': {
|
|
|
|
|
+ target: VITE_BASE_API,
|
|
|
|
|
+ changeOrigin: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ '/auth': {
|
|
|
|
|
+ target: VITE_BASE_API,
|
|
|
|
|
+ changeOrigin: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ '/gig': {
|
|
|
|
|
+ target: VITE_BASE_API,
|
|
|
|
|
+ changeOrigin: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|