Skip to content

Commit

Permalink
feat(cli): 增加支付宝小程序编译类型
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Oct 2, 2018
1 parent 9af132a commit 6619011
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/taro-cli/bin/taro-build
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { PROJECT_CONFIG } = require('../src/util')
const projectConfPath = path.join(process.cwd(), PROJECT_CONFIG)

program
.option('--type [typeName]', 'Build type, weapp/h5/rn/swan')
.option('--type [typeName]', 'Build type, weapp/h5/rn/swan/alipay')
.option('--watch', 'Watch mode')
.option('--env [env]', 'Env type')
.option('--ui', 'Build Taro UI library')
Expand Down
12 changes: 11 additions & 1 deletion packages/taro-cli/src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ function build (args, buildConfig) {
case Util.BUILD_TYPES.SWAN:
buildForSwan({ watch })
break
case Util.BUILD_TYPES.ALIPAY:
buildForAlipay({ watch })
break
case Util.BUILD_TYPES.RN:
buildForRN({ watch })
break
case Util.BUILD_TYPES.UI:
buildForUILibrary({ watch })
break
default:
console.log(chalk.red('输入类型错误,目前只支持 weapp/h5/rn/swan 四端类型'))
console.log(chalk.red('输入类型错误,目前只支持 weapp/h5/rn/swan/alipay 五端类型'))
}
}

Expand All @@ -52,6 +55,13 @@ function buildForSwan ({ watch }) {
})
}

function buildForAlipay ({ watch }) {
require('./weapp').build({
watch,
adapter: Util.BUILD_TYPES.ALIPAY
})
}

function buildForH5 (buildConfig) {
require('./h5').build(buildConfig)
}
Expand Down
9 changes: 8 additions & 1 deletion packages/taro-cli/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const processTypeMap = {

exports.pocessTypeEnum = pocessTypeEnum

exports.CSS_EXT = ['.css', '.scss', '.sass', '.less', '.styl', '.wxss']
exports.CSS_EXT = ['.css', '.scss', '.sass', '.less', '.styl', '.wxss', '.acss']
exports.SCSS_EXT = ['.scss']
exports.JS_EXT = ['.js', '.jsx']
exports.TS_EXT = ['.ts', '.tsx']
Expand All @@ -84,6 +84,7 @@ exports.BUILD_TYPES = {
H5: 'h5',
RN: 'rn',
SWAN: 'swan',
ALIPAY: 'alipay',
UI: 'ui'
}

Expand All @@ -99,6 +100,12 @@ exports.MINI_APP_FILES = {
STYLE: '.css',
SCRIPT: '.js',
CONFIG: '.json'
},
[exports.BUILD_TYPES.ALIPAY]: {
TEMPL: '.axml',
STYLE: '.acss',
SCRIPT: '.js',
CONFIG: '.json'
}
}

Expand Down
14 changes: 14 additions & 0 deletions packages/taro-transformer-wx/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,27 @@ const swanAdapter: Adapter = {
type: Adapters.swan
}

const alipayAdapter: Adapter = {
if: 'a:if',
else: 'a:else',
elseif: 'a:elif',
for: 'a:for',
forItem: 'a:for-item',
forIndex: 'a:for-index',
key: 'a:key',
type: Adapters.swan
}

export let Adapter: Adapter = weixinAdapter

export function setAdapter (adapter: Adapters) {
switch (adapter) {
case Adapters.swan:
Adapter = swanAdapter
break
case Adapters.alipay:
Adapter = alipayAdapter
break
default:
Adapter = weixinAdapter
break
Expand Down

0 comments on commit 6619011

Please sign in to comment.