Skip to content

Commit

Permalink
fix(cli): 编译微信插件时需要对 plugin.json 指定的入口文件的后缀进行处理,close #4773
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Nov 6, 2019
1 parent 0131e95 commit f5b689d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/taro-cli/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function build (appPath: string, { watch, platform }: IBuildConfig)

function compilePluginJson (pluginJson, pluginPath) {
if (typeof pluginJson.main === 'string') {
pluginJson.main = pluginJson.main.replace(/.tsx$/, '.js')
pluginJson.main = pluginJson.main.replace(/\.tsx$|\.ts$/, '.js')
}
fs.writeJSONSync(pluginPath, pluginJson)
}
Expand Down Expand Up @@ -252,7 +252,12 @@ function wxPluginWatchFiles () {
if (filePath === outputFilePath) {
return
}
fs.copySync(filePath, outputFilePath)
const pluginJsonPath = path.join(sourceDir, PLUGIN_ROOT, PLUGIN_JSON)
if (filePath === pluginJsonPath) {
compilePluginJson(fs.readJSONSync(filePath), outputFilePath)
} else {
fs.copySync(filePath, outputFilePath)
}
}
}

Expand Down

0 comments on commit f5b689d

Please sign in to comment.