Skip to content

Commit

Permalink
fix(mini-runner): 修复静态资源引用的 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Dec 26, 2019
1 parent 6c02644 commit 8e188e3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions packages/taro-mini-runner/src/loaders/fileParseLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
taroJsRedux,
QUICKAPP_SPECIAL_COMPONENTS,
PARSE_AST_TYPE,
excludeReplaceTaroFrameworkPkgs
excludeReplaceTaroFrameworkPkgs,
REG_SCRIPTS
} from '../utils/constants'
import {
isNpmPkg,
Expand Down Expand Up @@ -289,10 +290,13 @@ function processAst ({
source.value = value
}
} else {
let vpath = resolveScriptPath(path.resolve(sourceFilePath, '..', value))
if (fs.existsSync(vpath)) {
value = promoteRelativePath(path.relative(sourceFilePath, vpath))
source.value = value.replace(path.extname(value), '')
const extname = path.extname(value)
if (!extname || REG_SCRIPTS.test(value)) {
let vpath = resolveScriptPath(path.resolve(sourceFilePath, '..', value))
if (fs.existsSync(vpath)) {
value = promoteRelativePath(path.relative(sourceFilePath, vpath))
source.value = value.replace(path.extname(value), '')
}
}
}
},
Expand Down Expand Up @@ -363,10 +367,13 @@ function processAst ({
args[0].value = value
}
} else {
const extname = path.extname(value)
let vpath = resolveScriptPath(path.resolve(sourceFilePath, '..', value))
if (fs.existsSync(vpath)) {
value = promoteRelativePath(path.relative(sourceFilePath, vpath))
args[0].value = value.replace(path.extname(value), '')
if (!extname || REG_SCRIPTS.test(value)) {
if (fs.existsSync(vpath)) {
value = promoteRelativePath(path.relative(sourceFilePath, vpath))
args[0].value = value.replace(path.extname(value), '')
}
}
}
}
Expand Down

0 comments on commit 8e188e3

Please sign in to comment.