Skip to content

Commit

Permalink
Merge pull request #15471 from phy-lei/fix/custom-framework-plugin
Browse files Browse the repository at this point in the history
fix: 当使用自定义的编译器编译时,不安装@tarojs/plugin-framework-react依赖会报错的bug
  • Loading branch information
koppthe committed Apr 11, 2024
2 parents d750582 + 17c7437 commit a6419e6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/taro-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import customCommand from './commands/customCommand'
import { getPkgVersion } from './util'

const DISABLE_GLOBAL_CONFIG_COMMANDS = ['build', 'global-config', 'doctor', 'update', 'config']
const DEFAULT_FRAMEWORK = 'react'

export default class CLI {
appPath: string
Expand Down Expand Up @@ -135,17 +136,16 @@ export default class CLI {
}

// 根据 framework 启用插件
const framework = kernel.config?.initialConfig.framework
switch (framework) {
case 'vue':
kernel.optsPlugins.push('@tarojs/plugin-framework-vue2')
break
case 'vue3':
kernel.optsPlugins.push('@tarojs/plugin-framework-vue3')
break
default:
kernel.optsPlugins.push('@tarojs/plugin-framework-react')
break
const framework = kernel.config?.initialConfig.framework || DEFAULT_FRAMEWORK
const frameworkMap = {
vue: '@tarojs/plugin-framework-vue2',
vue3: '@tarojs/plugin-framework-vue3',
react: '@tarojs/plugin-framework-react',
preact: '@tarojs/plugin-framework-react',
nerv: '@tarojs/plugin-framework-react',
}
if (frameworkMap[framework]) {
kernel.optsPlugins.push(frameworkMap[framework])
}

// 编译小程序插件
Expand Down

0 comments on commit a6419e6

Please sign in to comment.