fix(build) 按需加载插件支持屏蔽mobile-first模板

This commit is contained in:
zzcr 2023-05-18 07:13:09 -07:00
parent e39bb91bfd
commit 8cb490cf50
No known key found for this signature in database
GPG Key ID: F6C4DFD2EF53A673
1 changed files with 1 additions and 2 deletions

View File

@ -41,7 +41,6 @@ export default function vitePluginBabelImport(
return {
name: '@opentiny/vue-vite-import',
transform(code, id) {
const matchValue = mode === 'pc' ? './mobile' : './pc'
const isCheckMode = mode && /@opentiny\/vue-.+?\/lib\/index.js$/.test(id)
// 不处理node_modules内的依赖
if (/\.(?:[jt]sx?|vue)$/.test(id) && !/(node_modules)/.test(id)) {
@ -53,7 +52,7 @@ export default function vitePluginBabelImport(
map: null
}
} else if (isCheckMode) {
const newCode = code.replace(matchValue, `./${mode}`)
const newCode = code.replace(/("|').\/(mobile|pc|mobile-first)[.js]*("|')/g, `"./${mode}"`)
return {
code: newCode,
map: null