chore: 优化配置

This commit is contained in:
Huang 2022-09-19 16:25:30 +08:00
parent 6ca18b4bc2
commit 5ddc086f96
6 changed files with 866 additions and 836 deletions

View File

@ -2,6 +2,8 @@
VITE_PROD = false
VITE_DEV = true
VITE_PORT = 3000
# BASE_URL
VITE_BASE_URL = https://api-catch.ranesuangyu.top

View File

@ -1,6 +1,6 @@
{
"name": "vue3-Vite2-TS basic framework",
"version": "1.0.0",
"name": "uniapp_vue3_vite_ts",
"version": "1.0.2",
"scripts": {
"dev:app": "uni -p app",
"dev:custom": "uni -p",

1686
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

1
src/env.d.ts vendored
View File

@ -15,6 +15,7 @@ interface ImportMetaEnv {
readonly VITE_PROD: boolean;
readonly VITE_DEV: boolean;
readonly VITE_APP_CACHE_PREFIX: string;
readonly VITE_PORT: number;
}
interface ImportMeta {

View File

@ -1,8 +1,8 @@
{
"name" : "uni-preset-vue-ts",
"name" : "uniapp_vue3_vite_ts",
"appid" : "__UNI__38BE53A",
"description" : "",
"versionName" : "1.0.0",
"versionName" : "1.0.2",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */

View File

@ -3,6 +3,7 @@ import uni from '@dcloudio/vite-plugin-uni';
import eslintPlugin from 'vite-plugin-eslint';
import { resolve } from 'path';
import { loadEnv } from 'vite';
import { isProdMode } from './src/utils/env';
// https://vitejs.cn/config/
export default ({ mode }: ConfigEnv): UserConfig => {
@ -23,12 +24,14 @@ export default ({ mode }: ConfigEnv): UserConfig => {
terserOptions: {
compress: {
// 发布时删除 console
// drop_console: true,
drop_console: isProdMode(),
},
},
},
server: {
host: true,
open: true,
port: env.VITE_PORT as any,
proxy: {
'/api': {
target: env.VITE_BASE_URL,