49 lines
1015 B
JavaScript
49 lines
1015 B
JavaScript
import { defineConfig } from 'vite'
|
|
import uni from '@dcloudio/vite-plugin-uni'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
function resolveRootDir() {
|
|
try {
|
|
const url = typeof import.meta !== 'undefined' ? import.meta.url : ''
|
|
if (url) return path.dirname(fileURLToPath(url))
|
|
} catch (e) {
|
|
}
|
|
try {
|
|
if (typeof __dirname !== 'undefined') return __dirname
|
|
} catch (e) {
|
|
}
|
|
return process.cwd()
|
|
}
|
|
|
|
const rootDir = resolveRootDir()
|
|
|
|
export default defineConfig({
|
|
base: '/h5/',
|
|
plugins: [uni()],
|
|
resolve: {
|
|
alias: {
|
|
'@': rootDir,
|
|
},
|
|
},
|
|
server: {
|
|
host: '127.0.0.1',
|
|
port: 4403,
|
|
strictPort: true,
|
|
proxy: {
|
|
'/proxy-api': {
|
|
target: 'http://127.0.0.1:9000',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/proxy-api/, ''),
|
|
},
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
silenceDeprecations: ['legacy-js-api', 'color-functions', 'import'],
|
|
},
|
|
},
|
|
},
|
|
})
|