提交 ff6e385d 编写于 作者: fxy060608's avatar fxy060608

feat(x-android): 支持 import json

上级 2f2537df
......@@ -132,6 +132,16 @@ export function uniAppPlugin(): UniVitePlugin {
async transform(code, id) {
const { filename } = parseVueRequest(id)
if (!filename.endsWith('.uts') && !filename.endsWith('.ts')) {
if (filename.endsWith('.json')) {
const fileName = path.relative(inputDir, id)
this.emitFile({
type: 'asset',
fileName: normalizeEmitAssetFileName(
normalizeFilename(fileName, false)
),
source: code,
})
}
return
}
// 仅处理 uts 文件
......
......@@ -26,6 +26,7 @@ export function uniPrePlugin(options: UniPrePluginOptions = {}): Plugin {
const preHtmlFile = preUVueHtml
return {
name: 'uni:pre-android',
enforce: 'pre',
transform(code, id) {
if (!filter(id)) {
return
......
......@@ -227,10 +227,17 @@ export function requireUniHelpers() {
}
export function normalizeEmitAssetFileName(fileName: string) {
const extname = path.extname(fileName)
if (process.env.UNI_APP_X_TSC === 'true') {
if (path.extname(fileName) !== '.ts') {
if (extname !== '.ts') {
return fileName + '.ts'
}
} else {
// logo.png、pages.json 等
if (!['.ts', '.uts', '.uvue', '.vue'].includes(extname)) {
fileName = fileName + '.uts'
}
}
return fileName
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册