Skip to main content

Cross-Platform

Supported Platforms

Goji currently support these platforms. Each target has a target name.

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

Conditions in JavaScript code

The current target can be checked by process.env.TARGET in JavaScript code. This example shows how it works.

switch (process.env.TARGET) {
case 'wechat':
return 'Hello, WeChat!';
case 'baidu':
return 'Hello, Baidu!';
// ...
default:
return 'Unknown';
}

You should always use process.env.TARGET as a whole. Don't reassign process or process.env to another variable.

Conditions in config code

Only .config.js config file support conditions check of the target.

modele.exports = ({ target }) => {
if (target === 'alipay') {
return {
defaultTitle: '预订详情',
};
} else {
return {
navigationBarTitleText: '预订详情',
};
}
};

[Proposal] Wrong config file may cause warning in some platforms. For example, if you use Alipay's filed defaultTitle in WeChat Mini Program you may see this warning. image To fix this issue we can use implement a new package @goji/config-generator which can auto adjust the config files for different platforms.