Skip to main content

Setup

Requirements

We recommend to use nvm to control the version of Node.JS

Initialization

We recommend to initial a new Goji project by create-goji-app.

For npm users,

npm create goji-app my-goji-app
cd my-goji-app
npm install

For yarn users,

yarn create goji-app my-goji-app
cd my-goji-app
yarn

The Goji project will be created in folder my-goji-app, you can change it if you'd like.

The project folder's structure looks like this.

my-goji-app/
├── goji.config.js
├── package.json
└── src
├── app.config.ts
├── app.css
├── app.ts
├── pages
│   └── index
│   ├── index.config.ts
│   ├── index.css
│   └── index.tsx
└── project.config.json

Start development

To start a Goji project, you can run npm run start [target] for development mode, or run npm run build [target] for production mode.

yarn users should run yarn start [target] or yarn build [target]

The target filed defaults to wechat and could be set to one of this list.

Platformtarget
WeChat Mini Programwechat
Baidu Smart Programbaidu
Alipay Mini Programalipay
Toutiao Micro Apptoutiao
QQ Mini Programqq

WeChat Mini Program

  1. Run npm run start wechat in my-goji-app folder.

  2. Open WeChat Devtools and login by scan the QR code.

  3. Import the project located at my-goji-app/dist/wechat. You should correct the appid according to your real project or just use a test account.

image

  1. You should see the demo project. The dev tool will auto-reload if any source code changed.

image

After developing the code, you can run npm run build wechat to bundle the code and then preview or upload the mini program. Please note uploading code requires a real appid rather than a test account.

Other mini program

Basically the steps are same as WeChat Mini Program. You should download the different dev tools from their official website.