All Projects → js-newbee → taro-best-practices

js-newbee / taro-best-practices

Licence: other
使用 Taro 开发微信小程序、编译 H5 + React Native 的最佳实践

Labels

Projects that are alternatives of or similar to taro-best-practices

taro2-to-3
让 Taro2 项目自动升级到 Taro3 项目⚒️。
Stars: ✭ 31 (-73.73%)
Mutual labels:  taro
taro-quick-start
Quick start project with Taro & Vue3 & TypeScript.
Stars: ✭ 35 (-70.34%)
Mutual labels:  taro
ztaro
一套基于taro, zoro的完整的微信小程序及h5开发解决方案
Stars: ✭ 37 (-68.64%)
Mutual labels:  taro
taro-icons
基于 Taro 的小程序图标库
Stars: ✭ 53 (-55.08%)
Mutual labels:  taro
my-taro
taro体验开发小程序
Stars: ✭ 14 (-88.14%)
Mutual labels:  taro
taroify
Taroify 是移动端组件库 Vant 的 Taro 版本,两者基于相同的视觉规范,提供一致的 API 接口,助力开发者快速搭建小程序应用。
Stars: ✭ 420 (+255.93%)
Mutual labels:  taro
natsuha-weather
Natsuha Weather for WeChat Mini Program.
Stars: ✭ 33 (-72.03%)
Mutual labels:  taro
gangxiaoer-taro
博雅塔小程序,基于Taro的版本,同步发布百度小程序,支付宝小程序。
Stars: ✭ 16 (-86.44%)
Mutual labels:  taro
ChineseBQB-client
🤣 开源表情包小程序
Stars: ✭ 81 (-31.36%)
Mutual labels:  taro
Taro-sign
Taro 开发的 思政教育签到小程序
Stars: ✭ 27 (-77.12%)
Mutual labels:  taro
mp-framework-benchmark
mp-framework-benchmark
Stars: ✭ 49 (-58.47%)
Mutual labels:  taro
taro-template
可用于生产环境的taro项目模版,技术栈:taro + taro-ui + typescript + dva / mobx + sass,无需过多关注项目配置,预置功能包括但不限于页面/组件/store/service模版一键生成/编译自动生成路由列表和组件入口/代码规范强制检查/请求拦截封装/小程序CI等,实现多端项目的高效快速开发。目前已有1.x / 2.x / 3.x 版本。
Stars: ✭ 59 (-50%)
Mutual labels:  taro
Gitter
Gitter for GitHub - 可能是目前颜值最高的GitHub微信小程序客户端
Stars: ✭ 3,555 (+2912.71%)
Mutual labels:  taro
taro-weapp
🎮一款提供餐桌,酒桌上小游戏的小程序。
Stars: ✭ 28 (-76.27%)
Mutual labels:  taro
patrick-wechat
⭐️🐟 questionnaire wechat app built with taro, taro-ui and heart. 微信问卷小程序
Stars: ✭ 74 (-37.29%)
Mutual labels:  taro
taro3-vue3-template
一个基于 Taro3 和 Vue3 框架微信小程序模版。 核心技术采用Taro3、Vue3、TypeScript、NutUi、Vux4/Pinia、VueUse
Stars: ✭ 115 (-2.54%)
Mutual labels:  taro
jza-taro
[UNMATAINED] 小程序 for 吉珠小助手
Stars: ✭ 25 (-78.81%)
Mutual labels:  taro
Taro-ParserRichText
适用于 Taro 的小程序富文本组件
Stars: ✭ 32 (-72.88%)
Mutual labels:  taro
classmate-map
🧭 一款设计精美、体验优良的地图信息展示小程序,一个更有意思的同学录,可以在小程序中查看班级同学的毕业去向以及地域分布,多联(蹭)系(饭)。
Stars: ✭ 79 (-33.05%)
Mutual labels:  taro
taroCloud
记日常、GitHub trending资讯小程序 taro-hooks + rematch+云开发
Stars: ✭ 25 (-78.81%)
Mutual labels:  taro

taro-best-practices

使用 Taro 开发微信小程序、编译 H5 + React Native 的最佳实践

鉴于只开发微信小程序跟实现多端编译需要考虑的点有所不同,将这两部分内容进行了拆分:

目录

设置路径别名 alias

Taro v1.2.0 版本已支持设置路径别名

// config/index.js
const path = require('path')
// ...
alias: {
  '@components': path.resolve(__dirname, '..', 'src/components'),
  '@utils': path.resolve(__dirname, '..', 'src/utils')
}

但若要在 Sass 中使用别名,如 @styles 指向 src/styles

@import "@styles/theme.scss";

还需要额外的配置(Taro 对样式的处理是 node-sass -> postcss,在 sass 这步就报错了,不能用 postcss-import 插件解决):

// config/index.js
plugins: {
  sass: {
    importer: function(url) {
      const reg = /^@styles\/(.*)/
      return {
        file: reg.test(url) ? path.resolve(__dirname, '..', 'src/styles', url.match(reg)[1]) : url
      }
    }
  }
}

备注:目前资源引用时仍无法使用别名,如 background: url('@assets/logo.png'),解决中

通过环境变量实现 config 的多元控制

通过 npm run devnpm run build 等命令可以区分 config,如果在某环境下还需要实现进一步区分,可以在 package.json 中的 scripts 加入环境变量

"scripts": {
  "dev:weapp:mock": "MOCK=1 npm run dev:weapp"
}

MOCK=1 可以在 config 中通过 process.env.MOCK 访问到

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].