feat: demo 全部展示,不需要变量控制

This commit is contained in:
Burt 2024-01-22 14:02:28 +08:00
parent 0943ddcbe0
commit e7262dc1db
3 changed files with 21 additions and 54 deletions

5
env/.env vendored
View File

@ -4,8 +4,3 @@ VITE_APP_PORT = 9000
# TODO: 记得修改
VITE_UNI_APPID = 'H5871D791'
VITE_WX_APPID = 'wxa2abb91f64032a2b'
# 生产环境小程序要过滤掉demo因为demo里面很多本地图片超过2M的主包大小
# 是否显示DEMO1-显示0-不显示
# TIPS可以通过新增 .env.local 改写
VITE_SHOW_DEMO=0

View File

@ -1,11 +1,4 @@
import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
import path from 'node:path'
import { loadEnv } from 'vite'
// 获取环境变量的范例
const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env'))
// console.log(env)
const { VITE_SHOW_DEMO } = env
export default defineUniPages({
globalStyle: {
@ -31,37 +24,19 @@ export default defineUniPages({
fontSize: '10px',
iconWidth: '24px',
spacing: '3px',
list:
VITE_SHOW_DEMO === '1'
? [
list: [
{
iconPath: 'static/tabbar/home.png',
selectedIconPath: 'static/tabbar/homeHL.png',
pagePath: 'pages/index/index',
text: '首页',
},
// 生产环境要注释掉demo所以分开来写
{
iconPath: 'static/tabbar/example.png',
selectedIconPath: 'static/tabbar/exampleHL.png',
pagePath: 'pages/demo/index',
text: '示例',
},
{
iconPath: 'static/tabbar/personal.png',
selectedIconPath: 'static/tabbar/personalHL.png',
pagePath: 'pages/my/index',
text: '我的',
},
]
: [
{
iconPath: 'static/tabbar/home.png',
selectedIconPath: 'static/tabbar/homeHL.png',
pagePath: 'pages/index/index',
text: '首页',
},
{
iconPath: 'static/tabbar/personal.png',
selectedIconPath: 'static/tabbar/personalHL.png',

View File

@ -49,10 +49,7 @@ export default ({ command, mode }) => {
envDir: './env', // 自定义env目录
plugins: [
UniPages({
exclude:
env.VITE_SHOW_DEMO === '1'
? ['**/components/**/**.*']
: ['**/components/**/**.*', '**/demo/**/**.*'],
exclude: ['**/components/**/**.*'],
homePage: 'pages/index/index',
subPackages: ['src/pages-sub'],
}),