pages.config.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
  2. import path from 'node:path'
  3. import { loadEnv } from 'vite'
  4. // 获取环境变量的范例
  5. const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env'))
  6. // console.log(env)
  7. const { VITE_SHOW_DEMO } = env
  8. export default defineUniPages({
  9. globalStyle: {
  10. navigationStyle: 'default',
  11. navigationBarTitleText: 'vue3-uniapp',
  12. navigationBarBackgroundColor: '#f8f8f8',
  13. navigationBarTextStyle: 'black',
  14. backgroundColor: '#FFFFFF',
  15. },
  16. easycom: {
  17. autoscan: true,
  18. custom: {
  19. '^fly-(.*)': '@/components/fly-$1/fly-$1.vue',
  20. '^uni-(.*)': '@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue',
  21. },
  22. },
  23. tabBar: {
  24. color: '#999999',
  25. selectedColor: '#018d71',
  26. backgroundColor: '#F8F8F8',
  27. borderStyle: 'black',
  28. height: '50px',
  29. fontSize: '10px',
  30. iconWidth: '24px',
  31. spacing: '3px',
  32. list:
  33. VITE_SHOW_DEMO === '1'
  34. ? [
  35. {
  36. iconPath: 'static/tabbar/home.png',
  37. selectedIconPath: 'static/tabbar/homeHL.png',
  38. pagePath: 'pages/index/index',
  39. text: '首页',
  40. },
  41. // 生产环境要注释掉demo,所以分开来写
  42. {
  43. iconPath: 'static/tabbar/example.png',
  44. selectedIconPath: 'static/tabbar/exampleHL.png',
  45. pagePath: 'pages/demo/index',
  46. text: '示例',
  47. },
  48. {
  49. iconPath: 'static/tabbar/personal.png',
  50. selectedIconPath: 'static/tabbar/personalHL.png',
  51. pagePath: 'pages/my/index',
  52. text: '我的',
  53. },
  54. ]
  55. : [
  56. {
  57. iconPath: 'static/tabbar/home.png',
  58. selectedIconPath: 'static/tabbar/homeHL.png',
  59. pagePath: 'pages/index/index',
  60. text: '首页',
  61. },
  62. {
  63. iconPath: 'static/tabbar/personal.png',
  64. selectedIconPath: 'static/tabbar/personalHL.png',
  65. pagePath: 'pages/my/index',
  66. text: '我的',
  67. },
  68. ],
  69. },
  70. // 你也可以定义 pages 字段,它具有最高的优先级。
  71. pages: [],
  72. /**
  73. * subPackages 扫描的目录,例如:src/pages-sub
  74. * @type SubPackage[] | undefined
  75. */
  76. subPackages: undefined,
  77. })