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

chore(nvue): ignore wxs

上级 68735cbc
......@@ -13,7 +13,7 @@ const BLOCK_RE = /<\/block>/
const WXS_LANG_RE = /lang=["|'](renderjs|wxs)["|']/
const WXS_ATTRS = ['wxs', 'renderjs']
export function parseVueCode(code: string) {
export function parseVueCode(code: string, isNVue = false) {
const hasBlock = BLOCK_RE.test(code)
const hasWxs = WXS_LANG_RE.test(code)
if (!hasBlock && !hasWxs) {
......@@ -27,7 +27,7 @@ export function parseVueCode(code: string) {
// 重新解析新的 code
ast = parseVue(code, errors)
}
if (hasWxs) {
if (!isNVue && hasWxs) {
const wxsNodes = parseWxsNodes(ast)
code = parseWxsCode(wxsNodes, code)
// add watch
......
......@@ -11,8 +11,12 @@ import {
} from '@dcloudio/uni-cli-shared'
export function uniPreVuePlugin(): Plugin {
let isNVue = false
return {
name: 'uni:pre-vue',
config(config) {
isNVue = (config as any).nvue
},
async transform(code, id) {
const { filename, query } = parseVueRequest(id)
if (query.vue) {
......@@ -26,7 +30,7 @@ export function uniPreVuePlugin(): Plugin {
removeExt(normalizeMiniProgramFilename(id, process.env.UNI_INPUT_DIR))
)
return {
code: parseVueCode(code).code, // 暂不提供sourcemap,意义不大
code: parseVueCode(code, isNVue).code, // 暂不提供sourcemap,意义不大
map: null,
}
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册