@mpxjs/webpack-plugin 2.10.16-beta.13 → 2.10.16-beta.14
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.
|
@@ -39,21 +39,31 @@ module.exports = class AddModePlugin {
|
|
|
39
39
|
|
|
40
40
|
const queryObj = parseQuery(request.query || '?')
|
|
41
41
|
const queryInfix = queryObj.infix
|
|
42
|
-
if (!implicitMode) queryObj.mode = mode
|
|
43
|
-
queryObj.infix = `${queryInfix || ''}.${mode}`
|
|
44
42
|
|
|
45
43
|
// 如果已经确认是mode后缀的文件,添加query与mode后直接返回
|
|
46
44
|
if (modePattern.test(path.basename(resourcePath))) {
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// 已经被resolved到对应mode的文件,避免重复添加mode
|
|
46
|
+
const isResolved = (implicitMode || queryObj.mode === mode) && modePattern.test(queryObj.infix)
|
|
47
|
+
if (!isResolved) {
|
|
48
|
+
queryObj.infix = `${queryInfix || ''}.${mode}`
|
|
49
|
+
if (!implicitMode) queryObj.mode = mode
|
|
50
|
+
request.query = stringifyQuery(queryObj)
|
|
51
|
+
request.mode = obj.mode
|
|
52
|
+
}
|
|
49
53
|
return callback()
|
|
50
54
|
} else if (defaultMode && defaultModePattern.test(path.basename(resourcePath))) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
const isResolved = (implicitMode || queryObj.mode === mode) && defaultModePattern.test(queryObj.infix)
|
|
56
|
+
if (!isResolved) {
|
|
57
|
+
queryObj.infix = `${queryInfix || ''}.${defaultMode}`
|
|
58
|
+
if (!implicitMode) queryObj.mode = mode
|
|
59
|
+
request.query = stringifyQuery(queryObj)
|
|
60
|
+
request.mode = obj.mode
|
|
61
|
+
}
|
|
54
62
|
return callback()
|
|
55
63
|
}
|
|
56
64
|
|
|
65
|
+
if (!implicitMode) queryObj.mode = mode
|
|
66
|
+
queryObj.infix = `${queryInfix || ''}.${mode}`
|
|
57
67
|
obj.query = stringifyQuery(queryObj)
|
|
58
68
|
obj.path = addInfix(resourcePath, mode, extname)
|
|
59
69
|
obj.relativePath = request.relativePath && addInfix(request.relativePath, mode, extname)
|