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_PROD = false
VITE_DEV = true VITE_DEV = true
VITE_PORT = 3000
# BASE_URL # BASE_URL
VITE_BASE_URL = https://api-catch.ranesuangyu.top VITE_BASE_URL = https://api-catch.ranesuangyu.top

View File

@ -1,6 +1,6 @@
{ {
"name": "vue3-Vite2-TS basic framework", "name": "uniapp_vue3_vite_ts",
"version": "1.0.0", "version": "1.0.2",
"scripts": { "scripts": {
"dev:app": "uni -p app", "dev:app": "uni -p app",
"dev:custom": "uni -p", "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_PROD: boolean;
readonly VITE_DEV: boolean; readonly VITE_DEV: boolean;
readonly VITE_APP_CACHE_PREFIX: string; readonly VITE_APP_CACHE_PREFIX: string;
readonly VITE_PORT: number;
} }
interface ImportMeta { interface ImportMeta {

View File

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

View File

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