Giter VIP home page Giter VIP logo

taro-starter's Introduction

Taro-Starter

action Release Date GitHub last commit tag license

基于 Typescript、 React 构建 Taro 应用脚手架。用于快速开始一个 Taro 项目开发。 Taro 版本为 3.5.11

在线预览

Features

  • Babel 支持
  • Typescript 支持
  • React 支持
  • Sass 支持
  • png|svg|jpg|jpeg|gif 引入支持
  • git commit hooks, no 💩

Environment

Node 建议使用 Node 14+ 或更高版本。开发工具建议使用 VS Code

Usage

# clone the project
git clone [email protected]:funnyzak/taro-starter.git -b master ./taro-react-app

# enter the project directory and install dependency
cd ./taro-react-app && yarn

# develop h5
yarn dev:h5

# develop weapp
yarn dev:weapp

# build h5
yarn build:h5

# eslint
yarn eslint:check

# eslint:fix
yarn eslint:fix

# prettier check
yarn prettier:check

# prettier fix
yarn prettier:fix

# eslint and prettier check
yarn lint:check

# eslint and prettier fix
yarn lint:fix

# clean node_modules
yarn clean

More scripts, please see package.json

Build

打包默认的输出目录为:dist/[platform]

# 打包H5 输出到: dist/ht
yarn build:h5

# 打包微信小程序, 输出到:dist/weapp
yarn build:weapp

Structure

├── babel.config.js        // babel 配置
├── config                 // 开发和构建打包webpack配置
│   ├── dev.js             // 开发配置
│   ├── index.js           // 默认配置
│   └── prod.js            // 生产构建配置
├── global.d.ts            // typescript 全局声明文件
├── package.json           // 包信息
├── project.config.json    // 公共程序配置
├── public                 // 静态资源文件夹
├── src                    // 源码
│   ├── api                // api接口
│   ├── app.config.ts      // 根程序配置
│   ├── app.scss           // 入口全局样式
│   ├── app.ts             // 入口main文件
│   ├── components         // 公共组件
│   ├── config             // 项目全局配置包含变脸配置
│   ├── types              // 定义声明
│   ├── images             // 图片
│   ├── index.html         // 打包html模板
│   ├── pages              // 页面
│   ├── styles             // 公共样式
│   └── utils              // 工具类
├── tsconfig.json          // typescript 编译配置
└── tslint.json            // tslint 配置

Q&A

如何打包或开发指定应用配置?

  1. config/ 目录下,复制 app_sample.js 文件,重命名为 app_youname.js,并修改配置;
  2. 修改配置文件的环境变量配置;
  3. 使用 npx cross-env APP_ENV=app_youname yarn dev:h5 命令启动开发;
  4. 使用 npx cross-env APP_ENV=app_youname yarn build:h5 命令进行打包(打包输出目录为 dist/app/yourname)。

升级Taro

# 升级 Taro CLI 工具:
yarn add -D @tarojs/cli@latest

# 更新项目中 Taro 相关的依赖:
npx taro update project

# 重新安装依赖:
rm -rf ./node_modules && npm install

TypeScript 建议

  • 使用 tslint 作为编辑器内置的 linter
  • 使用 eslint 命令行工具配合 typescript-eslint-parsereslint-config-taro(见 .eslintrc) 作为 precommit 或者 prepush 的钩子,在提交或 commit 或编译出现问题时检查代码是否符合 Taro 规范
  • 不要在 TypeScript 使用 Redux 的 connect 装饰器,使用普通的函数写法,详情见: #9951
  • 当你的项目不那么复杂时,可以不使用 Redux

Reference

Contribution

如果你有任何的想法或者意见,欢迎提 Issue 或者 PR。

License

MIT License © 2022 funnyzak

taro-starter's People

Contributors

leida1983 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.