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

fix(uvue): 修复 web 平台解析uts代码

上级 2713e6fb
......@@ -121,7 +121,7 @@ export function initPluginVueOptions(
if (!compilerOptions.nodeTransforms) {
compilerOptions.nodeTransforms = []
}
if (options.platform === 'h5') {
if (options.platform === 'h5' || options.platform === 'web') {
templateOptions.transformAssetUrls = createUniVueTransformAssetUrls(
isExternalUrl(options.base) ? options.base : ''
)
......@@ -150,13 +150,35 @@ export function initPluginVueOptions(
;(compilerOptions as any).root = process.env.UNI_INPUT_DIR
const isX = process.env.UNI_APP_X === 'true'
// app-nvue | app-uvue 需要启用 customElement 机制来内联 styles
if (process.env.UNI_COMPILER === 'nvue' || isX) {
if (
process.env.UNI_COMPILER === 'nvue' ||
(isX && options.platform === 'app')
) {
vueOptions.customElement = true
if (process.env.UNI_RENDERER_NATIVE !== 'appService' || isX) {
// nvue 需要使用自己的 compiler,来移除 scoped
vueOptions.compiler = createNVueCompiler()
}
}
if (isX) {
if (!vueOptions.script) {
vueOptions.script = {
babelParserPlugins: [],
}
}
if (!vueOptions.script.babelParserPlugins) {
vueOptions.script.babelParserPlugins = []
}
if (!vueOptions.script.babelParserPlugins.includes('typescript')) {
vueOptions.script.babelParserPlugins.push('typescript')
}
// TODO 是不是应该 decorators
if (!vueOptions.script.babelParserPlugins.includes('decorators-legacy')) {
vueOptions.script.babelParserPlugins.push('decorators-legacy')
}
}
return vueOptions
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册