@mpxjs/webpack-plugin 2.7.50 → 2.7.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +3 -3
- package/lib/template-compiler/compiler.js +30 -16
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1420,11 +1420,11 @@ try {
|
|
|
1420
1420
|
let mpxStyleLoaderIndex = -1
|
|
1421
1421
|
loaders.forEach((loader, index) => {
|
|
1422
1422
|
const currentLoader = toPosix(loader.loader)
|
|
1423
|
-
if (currentLoader.includes('css-loader')) {
|
|
1423
|
+
if (currentLoader.includes('css-loader') && cssLoaderIndex === -1) {
|
|
1424
1424
|
cssLoaderIndex = index
|
|
1425
|
-
} else if (currentLoader.includes('vue-loader/lib/loaders/stylePostLoader')) {
|
|
1425
|
+
} else if (currentLoader.includes('vue-loader/lib/loaders/stylePostLoader') && vueStyleLoaderIndex === -1) {
|
|
1426
1426
|
vueStyleLoaderIndex = index
|
|
1427
|
-
} else if (currentLoader.includes(styleCompilerPath)) {
|
|
1427
|
+
} else if (currentLoader.includes(styleCompilerPath) && mpxStyleLoaderIndex === -1) {
|
|
1428
1428
|
mpxStyleLoaderIndex = index
|
|
1429
1429
|
}
|
|
1430
1430
|
})
|
|
@@ -1957,7 +1957,7 @@ function postProcessTemplate (el) {
|
|
|
1957
1957
|
}
|
|
1958
1958
|
}
|
|
1959
1959
|
|
|
1960
|
-
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd')
|
|
1960
|
+
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,noMode')
|
|
1961
1961
|
|
|
1962
1962
|
const wrapRE = /^\((.*)\)$/
|
|
1963
1963
|
|
|
@@ -1989,32 +1989,46 @@ function processAtMode (el) {
|
|
|
1989
1989
|
return
|
|
1990
1990
|
}
|
|
1991
1991
|
|
|
1992
|
-
const conditionMap =
|
|
1993
|
-
|
|
1992
|
+
const conditionMap = new Map()
|
|
1994
1993
|
modeStr.split('|').forEach(item => {
|
|
1995
1994
|
const arr = item.split(':')
|
|
1996
|
-
const key = arr[0] ||
|
|
1997
|
-
conditionMap
|
|
1995
|
+
const key = arr[0] || 'noMode'
|
|
1996
|
+
conditionMap.set(key, arr.slice(1))
|
|
1998
1997
|
})
|
|
1999
1998
|
|
|
2000
|
-
const modeArr =
|
|
1999
|
+
const modeArr = [...conditionMap.keys()]
|
|
2001
2000
|
|
|
2002
2001
|
if (modeArr.every(i => isValidMode(i))) {
|
|
2003
2002
|
const attrValue = getAndRemoveAttr(el, attrName).val
|
|
2004
2003
|
const replacedAttrName = attrArr.join('@')
|
|
2005
|
-
|
|
2006
2004
|
const processedAttr = { name: replacedAttrName, value: attrValue }
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2005
|
+
|
|
2006
|
+
for (let [defineMode, defineEnvArr] of conditionMap.entries()) {
|
|
2007
|
+
if (defineMode === 'noMode' || defineMode === mode) {
|
|
2008
|
+
// 命中 env 规则(没有定义env 或者定义的envArr包含当前env)
|
|
2009
|
+
if (!defineEnvArr.length || defineEnvArr.includes(env)) {
|
|
2010
|
+
el._atModeStatus = ''
|
|
2011
|
+
if (!replacedAttrName) {
|
|
2012
|
+
// 若defineMode 为 noMode,则不论是element,还是attr,都需要经过规则转换
|
|
2013
|
+
if (defineMode !== 'noMode') {
|
|
2014
|
+
el._atModeStatus = 'match'
|
|
2015
|
+
}
|
|
2016
|
+
} else {
|
|
2017
|
+
// 如果命中了指定的mode,则先存在el上,等跑完转换后再挂回去
|
|
2018
|
+
el.noTransAttrs ? el.noTransAttrs.push(processedAttr) : el.noTransAttrs = [processedAttr]
|
|
2019
|
+
}
|
|
2020
|
+
// 命中mode,命中env,完成匹配,直接退出
|
|
2021
|
+
break
|
|
2022
|
+
} else if (!replacedAttrName) {
|
|
2023
|
+
// 命中mode规则,没有命中当前env规则,设置为 'mismatch'
|
|
2024
|
+
el._atModeStatus = 'mismatch'
|
|
2025
|
+
}
|
|
2026
|
+
} else if (!replacedAttrName) {
|
|
2027
|
+
// 没有命中当前mode规则,设置为 'mismatch'
|
|
2028
|
+
el._atModeStatus = 'mismatch'
|
|
2010
2029
|
} else {
|
|
2011
|
-
//
|
|
2012
|
-
el.noTransAttrs ? el.noTransAttrs.push(processedAttr) : el.noTransAttrs = [processedAttr]
|
|
2030
|
+
// 如果没命中指定的mode,则该属性删除
|
|
2013
2031
|
}
|
|
2014
|
-
} else if (!replacedAttrName) {
|
|
2015
|
-
el._atModeStatus = 'mismatch'
|
|
2016
|
-
} else {
|
|
2017
|
-
// 如果没命中指定的mode,则该属性删除
|
|
2018
2032
|
}
|
|
2019
2033
|
}
|
|
2020
2034
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.52",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=14.14.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "187abad504151455e045c0adf2fe7f81412e0fef"
|
|
84
84
|
}
|