feat: demo 全部展示,不需要变量控制
This commit is contained in:
parent
0943ddcbe0
commit
e7262dc1db
5
env/.env
vendored
5
env/.env
vendored
@ -4,8 +4,3 @@ VITE_APP_PORT = 9000
|
||||
# TODO: 记得修改
|
||||
VITE_UNI_APPID = 'H5871D791'
|
||||
VITE_WX_APPID = 'wxa2abb91f64032a2b'
|
||||
|
||||
# 生产环境小程序要过滤掉demo,因为demo里面很多本地图片,超过2M的主包大小
|
||||
# 是否显示DEMO,1-显示,0-不显示
|
||||
# TIPS:可以通过新增 .env.local 改写
|
||||
VITE_SHOW_DEMO=0
|
||||
|
@ -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,44 +24,26 @@ export default defineUniPages({
|
||||
fontSize: '10px',
|
||||
iconWidth: '24px',
|
||||
spacing: '3px',
|
||||
list:
|
||||
VITE_SHOW_DEMO === '1'
|
||||
? [
|
||||
{
|
||||
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',
|
||||
pagePath: 'pages/my/index',
|
||||
text: '我的',
|
||||
},
|
||||
],
|
||||
list: [
|
||||
{
|
||||
iconPath: 'static/tabbar/home.png',
|
||||
selectedIconPath: 'static/tabbar/homeHL.png',
|
||||
pagePath: 'pages/index/index',
|
||||
text: '首页',
|
||||
},
|
||||
{
|
||||
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: '我的',
|
||||
},
|
||||
],
|
||||
},
|
||||
// 你也可以定义 pages 字段,它具有最高的优先级。
|
||||
pages: [],
|
||||
|
@ -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'],
|
||||
}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user