2023-10-23 14:03:29 +00:00
|
|
|
import path from 'node:path'
|
2023-12-27 06:21:13 +00:00
|
|
|
import process from 'node:process'
|
2022-10-22 12:51:16 +00:00
|
|
|
import { loadEnv } from 'vite'
|
|
|
|
|
import type { ConfigEnv, UserConfig } from 'vite'
|
2023-03-01 15:25:47 +00:00
|
|
|
import viewport from 'postcss-mobile-forever'
|
2022-12-02 05:46:03 +00:00
|
|
|
import autoprefixer from 'autoprefixer'
|
2024-02-08 07:14:51 +00:00
|
|
|
import { createVitePlugins } from './build/vite'
|
2024-05-14 01:49:40 +00:00
|
|
|
import { exclude, include } from './build/vite/optimize'
|
2022-12-02 05:46:03 +00:00
|
|
|
|
2024-02-08 07:14:51 +00:00
|
|
|
export default ({ mode }: ConfigEnv): UserConfig => {
|
2022-10-22 12:51:16 +00:00
|
|
|
const root = process.cwd()
|
|
|
|
|
const env = loadEnv(mode, root)
|
2022-12-10 08:47:37 +00:00
|
|
|
|
2022-06-04 07:07:46 +00:00
|
|
|
return {
|
|
|
|
|
base: env.VITE_APP_PUBLIC_PATH,
|
2024-10-14 04:37:53 +00:00
|
|
|
plugins: createVitePlugins(mode),
|
2022-06-23 07:08:08 +00:00
|
|
|
|
2024-02-08 07:14:51 +00:00
|
|
|
server: {
|
|
|
|
|
host: true,
|
|
|
|
|
port: 3000,
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: '',
|
|
|
|
|
ws: false,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-02-04 15:45:43 +00:00
|
|
|
|
2024-02-08 07:14:51 +00:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'~@': path.join(__dirname, './src'),
|
|
|
|
|
'@': path.join(__dirname, './src'),
|
|
|
|
|
'~': path.join(__dirname, './src/assets'),
|
2024-08-26 08:20:12 +00:00
|
|
|
'~root': path.join(__dirname, '.'),
|
2024-02-08 07:14:51 +00:00
|
|
|
},
|
|
|
|
|
},
|
2022-06-23 07:43:05 +00:00
|
|
|
|
2022-12-02 05:46:03 +00:00
|
|
|
css: {
|
|
|
|
|
postcss: {
|
|
|
|
|
plugins: [
|
|
|
|
|
autoprefixer(),
|
2024-04-03 06:58:34 +00:00
|
|
|
// https://github.com/wswmsword/postcss-mobile-forever
|
2023-03-01 15:25:47 +00:00
|
|
|
viewport({
|
2023-10-23 14:03:29 +00:00
|
|
|
appSelector: '#app',
|
2022-12-02 05:46:03 +00:00
|
|
|
viewportWidth: 375,
|
2023-10-23 14:03:29 +00:00
|
|
|
maxDisplayWidth: 600,
|
2025-02-19 03:04:11 +00:00
|
|
|
appContainingBlock: 'auto',
|
2024-10-08 12:06:25 +00:00
|
|
|
border: true,
|
2022-12-02 05:46:03 +00:00
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2022-06-23 07:43:05 +00:00
|
|
|
build: {
|
|
|
|
|
cssCodeSplit: false,
|
2022-09-29 09:32:29 +00:00
|
|
|
chunkSizeWarningLimit: 2048,
|
2024-10-14 04:37:53 +00:00
|
|
|
outDir: env.VITE_APP_OUT_DIR || 'dist',
|
2022-06-23 07:43:05 +00:00
|
|
|
},
|
2024-05-14 01:49:40 +00:00
|
|
|
|
|
|
|
|
optimizeDeps: { include, exclude },
|
2022-10-22 12:51:16 +00:00
|
|
|
}
|
|
|
|
|
}
|