@mpxjs/webpack-plugin 2.6.104 → 2.6.109
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/extractor.js +2 -3
- package/lib/helpers.js +2 -3
- package/lib/index.js +19 -0
- package/lib/json-compiler/index.js +14 -14
- package/lib/loader.js +2 -2
- package/lib/platform/json/wx/index.js +7 -2
- package/lib/platform/template/wx/component-config/navigator.js +1 -1
- package/lib/plugin-loader.js +2 -2
- package/lib/runtime/components/web/getInnerListeners.js +51 -45
- package/lib/runtime/components/web/mpx-keep-alive.vue +4 -1
- package/lib/runtime/components/web/mpx-tab-bar-container.vue +2 -2
- package/lib/runtime/optionProcessor.js +2 -17
- package/lib/runtime/stringify.wxs +3 -3
- package/lib/staticConfig.js +4 -0
- package/lib/style-compiler/index.js +9 -4
- package/lib/template-compiler/bind-this.js +4 -4
- package/lib/template-compiler/compiler.js +99 -35
- package/lib/template-compiler/trans-dynamic-class-expr.js +3 -3
- package/lib/wxs/wxs-loader.js +4 -3
- package/lib/wxs/wxs-pre-loader.js +4 -4
- package/lib/wxss/processCss.js +44 -44
- package/package.json +7 -7
package/lib/extractor.js
CHANGED
|
@@ -23,9 +23,9 @@ module.exports = function (content) {
|
|
|
23
23
|
const mpx = mainCompilation.__mpx__
|
|
24
24
|
|
|
25
25
|
const pagesMap = mpx.pagesMap
|
|
26
|
+
const getOutputPath = mpx.getOutputPath
|
|
26
27
|
|
|
27
28
|
const extract = mpx.extract
|
|
28
|
-
const pathHash = mpx.pathHash
|
|
29
29
|
const extractedMap = mpx.extractedMap
|
|
30
30
|
const mode = mpx.mode
|
|
31
31
|
const typeExtMap = config[mode].typeExtMap
|
|
@@ -50,8 +50,7 @@ module.exports = function (content) {
|
|
|
50
50
|
if (filename) {
|
|
51
51
|
return filename + typeExtMap[type]
|
|
52
52
|
} else {
|
|
53
|
-
const
|
|
54
|
-
const outputPath = path.join(type, resourceName + pathHash(resourcePath) + typeExtMap[type])
|
|
53
|
+
const outputPath = getOutputPath(resourcePath, type, { ext: typeExtMap[type] })
|
|
55
54
|
return mpx.getPackageInfo({
|
|
56
55
|
resource: resourceRaw,
|
|
57
56
|
outputPath,
|
package/lib/helpers.js
CHANGED
|
@@ -96,7 +96,7 @@ function resolveLoaders ({ options, projectRoot }) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
module.exports = function createHelpers ({ loaderContext, options, moduleId, hasScoped,
|
|
99
|
+
module.exports = function createHelpers ({ loaderContext, options, moduleId, hasScoped, hasComment, usingComponents, srcMode, isNative, projectRoot }) {
|
|
100
100
|
const rawRequest = getRawRequest(loaderContext, options.excludedPreLoaders)
|
|
101
101
|
const {
|
|
102
102
|
defaultLoaders,
|
|
@@ -253,8 +253,7 @@ module.exports = function createHelpers ({ loaderContext, options, moduleId, has
|
|
|
253
253
|
styleCompiler = styleCompilerPath + '?' +
|
|
254
254
|
JSON.stringify({
|
|
255
255
|
moduleId,
|
|
256
|
-
scoped: !!scoped
|
|
257
|
-
ctorType: ctorType
|
|
256
|
+
scoped: !!scoped
|
|
258
257
|
})
|
|
259
258
|
// normalize scss/sass/postcss if no specific loaders have been provided
|
|
260
259
|
if (!loaders[lang]) {
|
package/lib/index.js
CHANGED
|
@@ -124,6 +124,7 @@ class MpxWebpackPlugin {
|
|
|
124
124
|
options.forceUsePageCtor = options.forceUsePageCtor || false
|
|
125
125
|
options.postcssInlineConfig = options.postcssInlineConfig || {}
|
|
126
126
|
options.transRpxRules = options.transRpxRules || null
|
|
127
|
+
options.webConfig = options.webConfig || {}
|
|
127
128
|
options.auditResource = options.auditResource || false
|
|
128
129
|
options.decodeHTMLText = options.decodeHTMLText || false
|
|
129
130
|
options.nativeOptions = Object.assign({
|
|
@@ -142,6 +143,7 @@ class MpxWebpackPlugin {
|
|
|
142
143
|
options.fileConditionRules = options.fileConditionRules || {
|
|
143
144
|
include: () => true
|
|
144
145
|
}
|
|
146
|
+
options.customOutputPath = options.customOutputPath || null
|
|
145
147
|
this.options = options
|
|
146
148
|
}
|
|
147
149
|
|
|
@@ -438,6 +440,7 @@ class MpxWebpackPlugin {
|
|
|
438
440
|
autoScopeRules: this.options.autoScopeRules,
|
|
439
441
|
autoVirtualHostRules: this.options.autoVirtualHostRules,
|
|
440
442
|
transRpxRules: this.options.transRpxRules,
|
|
443
|
+
webConfig: this.options.webConfig,
|
|
441
444
|
postcssInlineConfig: this.options.postcssInlineConfig,
|
|
442
445
|
decodeHTMLText: this.options.decodeHTMLText,
|
|
443
446
|
// native文件专用相关配置
|
|
@@ -484,6 +487,15 @@ class MpxWebpackPlugin {
|
|
|
484
487
|
}
|
|
485
488
|
return hash(hashPath)
|
|
486
489
|
},
|
|
490
|
+
getOutputPath: (resourcePath, type, { ext = '', conflictPath = '' } = {}) => {
|
|
491
|
+
const name = path.parse(resourcePath).name
|
|
492
|
+
const hash = mpx.pathHash(resourcePath)
|
|
493
|
+
const customOutputPath = this.options.customOutputPath
|
|
494
|
+
if (conflictPath) return conflictPath.replace(/(\.[^\\/]+)?$/, match => hash + match)
|
|
495
|
+
if (typeof customOutputPath === 'function') return customOutputPath(type, name, hash, ext)
|
|
496
|
+
if (type === 'component' || type === 'page') return path.join(type + 's', name + hash, 'index' + ext)
|
|
497
|
+
return path.join(type, name + hash + ext)
|
|
498
|
+
},
|
|
487
499
|
extract: (content, file, index, sideEffects) => {
|
|
488
500
|
index = index === -1 ? 0 : index
|
|
489
501
|
additionalAssets[file] = additionalAssets[file] || []
|
|
@@ -549,6 +561,13 @@ class MpxWebpackPlugin {
|
|
|
549
561
|
if (currentResourceMap[resourcePath] === outputPath) {
|
|
550
562
|
alreadyOutputed = true
|
|
551
563
|
} else {
|
|
564
|
+
for (let key in currentResourceMap) {
|
|
565
|
+
if (currentResourceMap[key] === outputPath && key !== resourcePath) {
|
|
566
|
+
outputPath = toPosix(path.join(packageRoot, mpx.getOutputPath(resourcePath, resourceType, { conflictPath: outputPath })))
|
|
567
|
+
warn && warn(new Error(`Current ${resourceType} [${resourcePath}] is registered with a conflict outputPath [${currentResourceMap[key]}] which is already existed in system, will be renamed with [${outputPath}], use ?resolve to get the real outputPath!`))
|
|
568
|
+
break
|
|
569
|
+
}
|
|
570
|
+
}
|
|
552
571
|
currentResourceMap[resourcePath] = outputPath
|
|
553
572
|
}
|
|
554
573
|
} else if (!currentResourceMap[resourcePath]) {
|
|
@@ -26,6 +26,7 @@ module.exports = function (raw = '{}') {
|
|
|
26
26
|
const options = loaderUtils.getOptions(this) || {}
|
|
27
27
|
const mainCompilation = getMainCompilation(this._compilation)
|
|
28
28
|
const mpx = mainCompilation.__mpx__
|
|
29
|
+
const getOutputPath = mpx.getOutputPath
|
|
29
30
|
|
|
30
31
|
const emitWarning = (msg) => {
|
|
31
32
|
this.emitWarning(
|
|
@@ -297,8 +298,7 @@ module.exports = function (raw = '{}') {
|
|
|
297
298
|
let relativePath = path.relative(root, resourceName)
|
|
298
299
|
outputPath = path.join('components', name + pathHash(root), relativePath)
|
|
299
300
|
} else {
|
|
300
|
-
|
|
301
|
-
outputPath = path.join('components', componentName + pathHash(resourcePath), componentName)
|
|
301
|
+
outputPath = getOutputPath(resourcePath, 'component')
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
const { packageRoot, outputPath: componentPath, alreadyOutputed } = mpx.getPackageInfo({
|
|
@@ -515,10 +515,10 @@ module.exports = function (raw = '{}') {
|
|
|
515
515
|
callback()
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
-
const getPageName = (resourcePath, ext) => {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
518
|
+
// const getPageName = (resourcePath, ext) => {
|
|
519
|
+
// const baseName = path.basename(resourcePath, ext)
|
|
520
|
+
// return path.join('pages', baseName + pathHash(resourcePath), baseName)
|
|
521
|
+
// }
|
|
522
522
|
|
|
523
523
|
const processPages = (pages, srcRoot = '', tarRoot = '', context, callback) => {
|
|
524
524
|
if (pages) {
|
|
@@ -552,18 +552,18 @@ module.exports = function (raw = '{}') {
|
|
|
552
552
|
const relative = path.relative(context, resourcePath)
|
|
553
553
|
if (/^\./.test(relative)) {
|
|
554
554
|
// 如果当前page不存在于context中,对其进行重命名
|
|
555
|
-
pageName =
|
|
555
|
+
pageName = getOutputPath(resourcePath, 'page')
|
|
556
556
|
emitWarning(`Current page [${resourcePath}] is not in current pages directory [${context}], the page path will be replaced with [${pageName}], use ?resolve to get the page path and navigate to it!`)
|
|
557
557
|
} else {
|
|
558
558
|
pageName = toPosix(path.join(tarRoot, /^(.*?)(\.[^.]*)?$/.exec(relative)[1]))
|
|
559
559
|
// 如果当前page与已有page存在命名冲突,也进行重命名
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
560
|
+
}
|
|
561
|
+
for (let key in pagesMap) {
|
|
562
|
+
if (pagesMap[key] === pageName && key !== resourcePath) {
|
|
563
|
+
const pageNameRaw = pageName
|
|
564
|
+
pageName = getOutputPath(resourcePath, 'page', { conflictPath: pageNameRaw })
|
|
565
|
+
emitWarning(`Current page [${resourcePath}] is registered with a conflict page path [${pageNameRaw}] which is already existed in system, the page path will be replaced with [${pageName}], use ?resolve to get the page path and navigate to it!`)
|
|
566
|
+
break
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
569
|
}
|
package/lib/loader.js
CHANGED
|
@@ -15,6 +15,7 @@ const processTemplate = require('./web/processTemplate')
|
|
|
15
15
|
const readJsonForSrc = require('./utils/read-json-for-src')
|
|
16
16
|
const normalize = require('./utils/normalize')
|
|
17
17
|
const getMainCompilation = require('./utils/get-main-compilation')
|
|
18
|
+
const { MPX_APP_MODULE_ID } = require('./staticConfig')
|
|
18
19
|
module.exports = function (content) {
|
|
19
20
|
this.cacheable()
|
|
20
21
|
|
|
@@ -88,7 +89,7 @@ module.exports = function (content) {
|
|
|
88
89
|
|
|
89
90
|
let moduleId = 'm' + mpx.pathHash(filePath)
|
|
90
91
|
if (ctorType === 'app') {
|
|
91
|
-
moduleId =
|
|
92
|
+
moduleId = MPX_APP_MODULE_ID
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
const parts = parseComponent(content, {
|
|
@@ -155,7 +156,6 @@ module.exports = function (content) {
|
|
|
155
156
|
options,
|
|
156
157
|
moduleId,
|
|
157
158
|
hasScoped,
|
|
158
|
-
ctorType,
|
|
159
159
|
hasComment,
|
|
160
160
|
usingComponents,
|
|
161
161
|
srcMode,
|
|
@@ -73,7 +73,12 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
73
73
|
swan: deletePath()
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
|
-
test: 'onReachBottomDistance
|
|
76
|
+
test: 'onReachBottomDistance',
|
|
77
|
+
qq: deletePath(),
|
|
78
|
+
jd: deletePath()
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
test: 'disableScroll',
|
|
77
82
|
ali: deletePath(),
|
|
78
83
|
qq: deletePath(),
|
|
79
84
|
jd: deletePath()
|
|
@@ -84,7 +89,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
84
89
|
swan: deletePath()
|
|
85
90
|
},
|
|
86
91
|
{
|
|
87
|
-
test: 'navigationBarTextStyle|navigationStyle|
|
|
92
|
+
test: 'navigationBarTextStyle|navigationStyle|backgroundTextStyle',
|
|
88
93
|
ali: deletePath()
|
|
89
94
|
},
|
|
90
95
|
{
|
|
@@ -44,7 +44,7 @@ module.exports = function ({ print }) {
|
|
|
44
44
|
// 如果是个变量,报warning~
|
|
45
45
|
aliPropLog(attr)
|
|
46
46
|
} else {
|
|
47
|
-
let supportedList = ['navigate', 'redirect', 'switchTab', 'navigateBack', 'reLaunch']
|
|
47
|
+
let supportedList = ['navigate', 'redirect', 'switchTab', 'navigateBack', 'reLaunch', 'exit']
|
|
48
48
|
if (supportedList.indexOf(attr.value) === -1) {
|
|
49
49
|
aliValueLogError(attr)
|
|
50
50
|
}
|
package/lib/plugin-loader.js
CHANGED
|
@@ -54,6 +54,7 @@ module.exports = function (source) {
|
|
|
54
54
|
const context = this.context
|
|
55
55
|
const packageName = 'main'
|
|
56
56
|
const pagesMap = mpx.pagesMap
|
|
57
|
+
const getOutputPath = mpx.getOutputPath
|
|
57
58
|
const componentsMap = mpx.componentsMap[packageName]
|
|
58
59
|
const getEntryNode = mpx.getEntryNode
|
|
59
60
|
const resolveMode = mpx.resolveMode
|
|
@@ -191,8 +192,7 @@ module.exports = function (source) {
|
|
|
191
192
|
let relativePath = path.relative(root, resourceName)
|
|
192
193
|
outputPath = path.join('components', name + pathHash(root), relativePath)
|
|
193
194
|
} else {
|
|
194
|
-
|
|
195
|
-
outputPath = path.join('components', componentName + pathHash(resourcePath), componentName)
|
|
195
|
+
outputPath = getOutputPath(resourcePath, 'component')
|
|
196
196
|
}
|
|
197
197
|
const componentPath = toPosix(outputPath)
|
|
198
198
|
pluginEntry.publicComponents[name] = componentPath
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isEmptyObject } from './util'
|
|
2
|
+
const isTouchDevice = 'ontouchstart' in document.documentElement
|
|
2
3
|
|
|
3
4
|
function processModel (listeners, context) {
|
|
4
5
|
// 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
|
|
@@ -54,58 +55,63 @@ function processTap (listeners, context) {
|
|
|
54
55
|
})
|
|
55
56
|
if (isEmptyObject(listenerMap)) return
|
|
56
57
|
context.__mpxTapInfo = context.__mpxTapInfo || {}
|
|
57
|
-
let events
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
let events
|
|
59
|
+
if (isTouchDevice) {
|
|
60
|
+
events = {
|
|
61
|
+
touchstart (e) {
|
|
62
|
+
context.__mpxTapInfo.detail = {
|
|
63
|
+
x: e.changedTouches[0].pageX,
|
|
64
|
+
y: e.changedTouches[0].pageY
|
|
65
|
+
}
|
|
66
|
+
context.__mpxTapInfo.startTimer = null
|
|
67
|
+
context.__mpxTapInfo.needTap = true
|
|
68
|
+
if (listenerMap.longpress || listenerMap.longtap) {
|
|
69
|
+
context.__mpxTapInfo.startTimer = setTimeout(() => {
|
|
70
|
+
context.__mpxTapInfo.needTap = false
|
|
71
|
+
if (listenerMap.longpress) {
|
|
72
|
+
const re = inheritEvent('longpress', e, context.__mpxTapInfo.detail)
|
|
73
|
+
context.$emit('longpress', re)
|
|
74
|
+
}
|
|
75
|
+
if (listenerMap.longtap) {
|
|
76
|
+
const re = inheritEvent('longtap', e, context.__mpxTapInfo.detail)
|
|
77
|
+
context.$emit('longtap', re)
|
|
78
|
+
}
|
|
79
|
+
}, 350)
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
touchmove (e) {
|
|
83
|
+
const tapDetailInfo = context.__mpxTapInfo.detail || {}
|
|
84
|
+
const currentPageX = e.changedTouches[0].pageX
|
|
85
|
+
const currentPageY = e.changedTouches[0].pageY
|
|
86
|
+
if (Math.abs(currentPageX - tapDetailInfo.x) > 1 || Math.abs(currentPageY - tapDetailInfo.y) > 1) {
|
|
68
87
|
context.__mpxTapInfo.needTap = false
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const re = inheritEvent('longtap', e, context.__mpxTapInfo.detail)
|
|
75
|
-
context.$emit('longtap', re)
|
|
76
|
-
}
|
|
77
|
-
}, 350)
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
touchmove (e) {
|
|
81
|
-
const tapDetailInfo = context.__mpxTapInfo.detail || {}
|
|
82
|
-
const currentPageX = e.changedTouches[0].pageX
|
|
83
|
-
const currentPageY = e.changedTouches[0].pageY
|
|
84
|
-
if (Math.abs(currentPageX - tapDetailInfo.x) > 1 || Math.abs(currentPageY - tapDetailInfo.y) > 1) {
|
|
85
|
-
context.__mpxTapInfo.needTap = false
|
|
88
|
+
context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
|
|
89
|
+
context.__mpxTapInfo.startTimer = null
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
touchend (e) {
|
|
86
93
|
context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
|
|
87
|
-
context.__mpxTapInfo.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
|
|
92
|
-
if (listenerMap.tap && context.__mpxTapInfo.needTap) {
|
|
93
|
-
const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
|
|
94
|
-
context.$emit('tap', re)
|
|
94
|
+
if (listenerMap.tap && context.__mpxTapInfo.needTap) {
|
|
95
|
+
const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
|
|
96
|
+
context.$emit('tap', re)
|
|
97
|
+
}
|
|
95
98
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
events = {
|
|
102
|
+
click (e) {
|
|
103
|
+
if (listenerMap.tap) {
|
|
104
|
+
context.__mpxTapInfo.detail = {
|
|
105
|
+
x: e.pageX,
|
|
106
|
+
y: e.pageY
|
|
107
|
+
}
|
|
108
|
+
const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
|
|
109
|
+
context.$emit('tap', re)
|
|
102
110
|
}
|
|
103
|
-
const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
|
|
104
|
-
context.$emit('tap', re)
|
|
105
111
|
}
|
|
106
|
-
context.__mpxTapInfo.hadTouch = false
|
|
107
112
|
}
|
|
108
113
|
}
|
|
114
|
+
|
|
109
115
|
mergeListeners(listeners, events, {
|
|
110
116
|
force: true
|
|
111
117
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { inBrowser } from '../../../utils/env'
|
|
3
|
+
|
|
3
4
|
function isDef (v) {
|
|
4
5
|
return v !== undefined && v !== null
|
|
5
6
|
}
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
|
|
31
32
|
function getVnodeKey (vnode) {
|
|
32
33
|
if (vnode && vnode.componentOptions) {
|
|
33
|
-
return vnode.
|
|
34
|
+
return vnode.componentOptions.Ctor.cid + (vnode.componentOptions.tag ? ('::' + (vnode.componentOptions.tag)) : '')
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -73,6 +74,8 @@
|
|
|
73
74
|
const current = stack[i - 1]
|
|
74
75
|
if (current.vnode && current.vnodeKey === vnodeKey && current.vnode.componentInstance) {
|
|
75
76
|
vnode.componentInstance = current.vnode.componentInstance
|
|
77
|
+
// 避免组件实例复用但是vnode.key不一致带来的bad case
|
|
78
|
+
vnode.key = current.vnode.key
|
|
76
79
|
break
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
'mpx-tab-bar': tabBarPagesMap['mpx-tab-bar']
|
|
16
16
|
}
|
|
17
17
|
tabBar.list.forEach(({ pagePath }) => {
|
|
18
|
-
const name = pagePath.replace(
|
|
18
|
+
const name = pagePath.replace(/\//g, '-')
|
|
19
19
|
const page = tabBarPagesMap[pagePath]
|
|
20
20
|
if (page) {
|
|
21
21
|
components[name] = page
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
currentComponent () {
|
|
40
40
|
const index = this.currentIndex
|
|
41
41
|
const tabItem = tabBar.list[index]
|
|
42
|
-
return tabItem.pagePath.replace(
|
|
42
|
+
return tabItem.pagePath.replace(/\//g, '-')
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
watch: {
|
|
@@ -25,23 +25,6 @@ export default function processOption (
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// 注册v-ex-classes自定义指令处理externalClasses
|
|
29
|
-
Vue.directive('ex-classes', (el, binding, vnode) => {
|
|
30
|
-
const context = vnode.context
|
|
31
|
-
if (context) {
|
|
32
|
-
const externalClasses = context.$options.externalClasses || []
|
|
33
|
-
const classList = el.classList
|
|
34
|
-
binding.value.forEach((className) => {
|
|
35
|
-
const actualExternalClassNames = context.$attrs[className]
|
|
36
|
-
if (externalClasses.indexOf(className) !== -1 && actualExternalClassNames) {
|
|
37
|
-
classList.remove(className)
|
|
38
|
-
actualExternalClassNames.split(/\s+/).forEach((actualExternalClassName) => {
|
|
39
|
-
if (actualExternalClassName) classList.add(actualExternalClassName)
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
28
|
Vue.directive('animation', (el, binding) => {
|
|
46
29
|
const newActions = binding && binding.value && binding.value.actions
|
|
47
30
|
if (el.actions === newActions) {
|
|
@@ -121,7 +104,9 @@ export default function processOption (
|
|
|
121
104
|
redirect: '/' + firstPage
|
|
122
105
|
})
|
|
123
106
|
}
|
|
107
|
+
const webRouteConfig = global.__mpx.config.webRouteConfig
|
|
124
108
|
global.__mpxRouter = option.router = new VueRouter({
|
|
109
|
+
...webRouteConfig,
|
|
125
110
|
routes: routes
|
|
126
111
|
})
|
|
127
112
|
global.__mpxRouter.stack = []
|
|
@@ -93,7 +93,7 @@ function isDef (v) {
|
|
|
93
93
|
return v !== undefined && v !== null
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
function
|
|
96
|
+
function stringifyDynamicClass (value) {
|
|
97
97
|
if (!value) return ''
|
|
98
98
|
if (likeArray(value)) {
|
|
99
99
|
return stringifyArray(value)
|
|
@@ -111,7 +111,7 @@ function stringifyArray (value) {
|
|
|
111
111
|
var res = ''
|
|
112
112
|
var stringified
|
|
113
113
|
for (var i = 0; i < value.length; i++) {
|
|
114
|
-
if (isDef(stringified =
|
|
114
|
+
if (isDef(stringified = stringifyDynamicClass(value[i])) && stringified !== '') {
|
|
115
115
|
if (res) res += ' '
|
|
116
116
|
res += stringified
|
|
117
117
|
}
|
|
@@ -207,7 +207,7 @@ module.exports = {
|
|
|
207
207
|
if (typeof staticClass !== 'string') {
|
|
208
208
|
return console.log('Template attr class must be a string!')
|
|
209
209
|
}
|
|
210
|
-
return concat(staticClass,
|
|
210
|
+
return concat(staticClass, stringifyDynamicClass(dynamicClass))
|
|
211
211
|
},
|
|
212
212
|
stringifyStyle: function (staticStyle, dynamicStyle) {
|
|
213
213
|
var normalizedDynamicStyle = normalizeDynamicStyle(dynamicStyle)
|
|
@@ -2,7 +2,7 @@ const getMainCompilation = require('../utils/get-main-compilation')
|
|
|
2
2
|
const postcss = require('postcss')
|
|
3
3
|
const loaderUtils = require('loader-utils')
|
|
4
4
|
const loadPostcssConfig = require('./load-postcss-config')
|
|
5
|
-
|
|
5
|
+
const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID } = require('../staticConfig')
|
|
6
6
|
const trim = require('./plugins/trim')
|
|
7
7
|
const rpx = require('./plugins/rpx')
|
|
8
8
|
const vw = require('./plugins/vw')
|
|
@@ -10,15 +10,20 @@ const pluginCondStrip = require('./plugins/conditional-strip')
|
|
|
10
10
|
const scopeId = require('./plugins/scope-id')
|
|
11
11
|
const transSpecial = require('./plugins/trans-special')
|
|
12
12
|
const matchCondition = require('../utils/match-condition')
|
|
13
|
+
const parseRequest = require('../utils/parse-request')
|
|
13
14
|
|
|
14
15
|
module.exports = function (css, map) {
|
|
15
16
|
this.cacheable()
|
|
16
17
|
const cb = this.async()
|
|
17
18
|
const loaderOptions = loaderUtils.getOptions(this) || {}
|
|
18
|
-
|
|
19
19
|
const mainCompilation = getMainCompilation(this._compilation)
|
|
20
20
|
const mpx = mainCompilation.__mpx__
|
|
21
21
|
const defs = mpx.defs
|
|
22
|
+
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
23
|
+
const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
|
|
24
|
+
const componentsMap = mpx.componentsMap[packageName]
|
|
25
|
+
const pagesMap = mpx.pagesMap
|
|
26
|
+
const isApp = (!componentsMap[resourcePath] && !pagesMap[resourcePath])
|
|
22
27
|
|
|
23
28
|
const transRpxRulesRaw = mpx.transRpxRules
|
|
24
29
|
|
|
@@ -85,8 +90,8 @@ module.exports = function (css, map) {
|
|
|
85
90
|
.process(css, options)
|
|
86
91
|
.then(result => {
|
|
87
92
|
// ali环境添加全局样式抹平root差异
|
|
88
|
-
if (mpx.mode === 'ali' &&
|
|
89
|
-
result.css +=
|
|
93
|
+
if (mpx.mode === 'ali' && isApp) {
|
|
94
|
+
result.css += `\n.${MPX_ROOT_VIEW} { display: initial }\n.${MPX_APP_MODULE_ID} { line-height: normal }`
|
|
90
95
|
}
|
|
91
96
|
if (result.messages) {
|
|
92
97
|
result.messages.forEach(({ type, file }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const babylon = require('
|
|
2
|
-
const traverse = require('babel
|
|
3
|
-
const t = require('babel
|
|
4
|
-
const generate = require('babel
|
|
1
|
+
const babylon = require('@babel/parser')
|
|
2
|
+
const traverse = require('@babel/traverse').default
|
|
3
|
+
const t = require('@babel/types')
|
|
4
|
+
const generate = require('@babel/generator').default
|
|
5
5
|
|
|
6
6
|
let names = 'Infinity,undefined,NaN,isFinite,isNaN,' +
|
|
7
7
|
'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const JSON5 = require('json5')
|
|
2
2
|
const he = require('he')
|
|
3
3
|
const config = require('../config')
|
|
4
|
+
const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID } = require('../staticConfig')
|
|
4
5
|
const normalize = require('../utils/normalize')
|
|
5
6
|
const isValidIdentifierStr = require('../utils/is-valid-identifier-str')
|
|
6
7
|
const isEmptyObject = require('../utils/is-empty-object')
|
|
@@ -1852,31 +1853,71 @@ function processAliExternalClassesHack (el, options) {
|
|
|
1852
1853
|
}
|
|
1853
1854
|
}
|
|
1854
1855
|
|
|
1856
|
+
// externalClasses只能模拟静态传递
|
|
1855
1857
|
function processWebExternalClassesHack (el, options) {
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
const externalClasses = []
|
|
1858
|
+
const staticClass = getAndRemoveAttr(el, 'class').val
|
|
1859
|
+
if (staticClass) {
|
|
1860
|
+
const classNames = staticClass.split(/\s+/)
|
|
1861
|
+
const replacements = []
|
|
1861
1862
|
options.externalClasses.forEach((className) => {
|
|
1862
|
-
const
|
|
1863
|
-
if (
|
|
1864
|
-
|
|
1863
|
+
const index = classNames.indexOf(className)
|
|
1864
|
+
if (index > -1) {
|
|
1865
|
+
replacements.push(`$attrs[${JSON.stringify(className)}]`)
|
|
1866
|
+
classNames.splice(index, 1)
|
|
1865
1867
|
}
|
|
1866
1868
|
})
|
|
1867
|
-
|
|
1869
|
+
|
|
1870
|
+
if (classNames.length) {
|
|
1871
|
+
addAttrs(el, [{
|
|
1872
|
+
name: 'class',
|
|
1873
|
+
value: classNames.join(' ')
|
|
1874
|
+
}])
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
if (replacements.length) {
|
|
1878
|
+
const dynamicClass = getAndRemoveAttr(el, ':class').val
|
|
1879
|
+
if (dynamicClass) replacements.push(dynamicClass)
|
|
1880
|
+
|
|
1868
1881
|
addAttrs(el, [{
|
|
1869
|
-
name: '
|
|
1870
|
-
value:
|
|
1882
|
+
name: ':class',
|
|
1883
|
+
value: `[${replacements.join(',')}]`
|
|
1871
1884
|
}])
|
|
1872
1885
|
}
|
|
1873
1886
|
}
|
|
1887
|
+
|
|
1888
|
+
// 处理externalClasses多层透传
|
|
1889
|
+
const isComponent = isComponentNode(el, options)
|
|
1890
|
+
if (isComponent) {
|
|
1891
|
+
options.externalClasses.forEach((classLikeAttrName) => {
|
|
1892
|
+
let classLikeAttrValue = getAndRemoveAttr(el, classLikeAttrName).val
|
|
1893
|
+
if (classLikeAttrValue) {
|
|
1894
|
+
const classNames = classLikeAttrValue.split(/\s+/)
|
|
1895
|
+
const replacements = []
|
|
1896
|
+
options.externalClasses.forEach((className) => {
|
|
1897
|
+
const index = classNames.indexOf(className)
|
|
1898
|
+
if (index > -1) {
|
|
1899
|
+
replacements.push(`$attrs[${JSON.stringify(className)}]`)
|
|
1900
|
+
classNames.splice(index, 1)
|
|
1901
|
+
}
|
|
1902
|
+
})
|
|
1903
|
+
|
|
1904
|
+
if (classNames.length) {
|
|
1905
|
+
replacements.unshift(JSON.stringify(classNames.join(' ')))
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
addAttrs(el, [{
|
|
1909
|
+
name: ':' + classLikeAttrName,
|
|
1910
|
+
value: `[${replacements.join(',')}].join(' ')`
|
|
1911
|
+
}])
|
|
1912
|
+
}
|
|
1913
|
+
})
|
|
1914
|
+
}
|
|
1874
1915
|
}
|
|
1875
1916
|
|
|
1876
1917
|
function processScoped (el, options) {
|
|
1877
1918
|
if (options.hasScoped && isRealNode(el)) {
|
|
1878
1919
|
const moduleId = options.moduleId
|
|
1879
|
-
const rootModuleId = options.isComponent ? '' :
|
|
1920
|
+
const rootModuleId = options.isComponent ? '' : MPX_APP_MODULE_ID // 处理app全局样式对页面的影响
|
|
1880
1921
|
const staticClass = getAndRemoveAttr(el, 'class').val
|
|
1881
1922
|
addAttrs(el, [{
|
|
1882
1923
|
name: 'class',
|
|
@@ -1899,38 +1940,58 @@ function processBuiltInComponents (el, meta) {
|
|
|
1899
1940
|
}
|
|
1900
1941
|
}
|
|
1901
1942
|
|
|
1902
|
-
function processAliStyleClassHack (el, options) {
|
|
1903
|
-
|
|
1943
|
+
function processAliStyleClassHack (el, options, root) {
|
|
1944
|
+
let processor
|
|
1945
|
+
// 处理组件标签
|
|
1946
|
+
if (isComponentNode(el, options)) processor = ({ value, typeName }) => [typeName, value]
|
|
1947
|
+
// 处理组件根节点
|
|
1948
|
+
if (options.isComponent && el === root && isRealNode(el)) {
|
|
1949
|
+
processor = ({ name, value, typeName }) => {
|
|
1950
|
+
let sep = name === 'style' ? ';' : ' '
|
|
1951
|
+
value = value ? `{{${typeName}||''}}${sep}${value}` : `{{${typeName}||''}}`
|
|
1952
|
+
return [name, value]
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
// 非上述两种不处理
|
|
1956
|
+
if (!processor) return
|
|
1957
|
+
// 处理style、class
|
|
1904
1958
|
['style', 'class'].forEach((type) => {
|
|
1905
1959
|
let exp = getAndRemoveAttr(el, type).val
|
|
1906
|
-
let typeName = 'mpx' + type.replace(/^./, (matched) =>
|
|
1907
|
-
|
|
1960
|
+
let typeName = 'mpx' + type.replace(/^./, (matched) => matched.toUpperCase())
|
|
1961
|
+
let [newName, newValue] = processor({
|
|
1962
|
+
name: type,
|
|
1963
|
+
value: exp,
|
|
1964
|
+
typeName
|
|
1908
1965
|
})
|
|
1909
|
-
if (
|
|
1966
|
+
if (newValue !== undefined) {
|
|
1910
1967
|
addAttrs(el, [{
|
|
1911
|
-
name:
|
|
1912
|
-
value:
|
|
1968
|
+
name: newName,
|
|
1969
|
+
value: newValue
|
|
1913
1970
|
}])
|
|
1914
1971
|
}
|
|
1915
1972
|
})
|
|
1916
1973
|
}
|
|
1974
|
+
|
|
1917
1975
|
// 有virtualHost情况wx组件注入virtualHost。无virtualHost阿里组件注入root-view。其他跳过。
|
|
1918
1976
|
function getVirtualHostRoot (options, meta) {
|
|
1919
|
-
if (
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1977
|
+
if (options.isComponent) {
|
|
1978
|
+
// 处理组件时
|
|
1979
|
+
if (mode === 'wx' && options.hasVirtualHost) {
|
|
1980
|
+
// wx组件注入virtualHost配置
|
|
1981
|
+
!meta.options && (meta.options = {})
|
|
1982
|
+
meta.options.virtualHost = true
|
|
1983
|
+
}
|
|
1984
|
+
if (mode === 'ali' && !options.hasVirtualHost) {
|
|
1985
|
+
// ali组件根节点实体化
|
|
1986
|
+
let rootView = createASTElement('view', [
|
|
1987
|
+
{
|
|
1988
|
+
name: 'class',
|
|
1989
|
+
value: `${MPX_ROOT_VIEW} host-${options.moduleId}`
|
|
1990
|
+
}
|
|
1991
|
+
])
|
|
1992
|
+
processElement(rootView, rootView, options, meta)
|
|
1993
|
+
return rootView
|
|
1994
|
+
}
|
|
1934
1995
|
}
|
|
1935
1996
|
return getTempNode()
|
|
1936
1997
|
}
|
|
@@ -1938,7 +1999,10 @@ function getVirtualHostRoot (options, meta) {
|
|
|
1938
1999
|
function processShow (el, options, root) {
|
|
1939
2000
|
let show = getAndRemoveAttr(el, config[mode].directive.show).val
|
|
1940
2001
|
if (mode === 'swan') show = wrapMustache(show)
|
|
1941
|
-
|
|
2002
|
+
let processFlag = el.parent === root
|
|
2003
|
+
// 当ali且未开启virtualHost时,mpxShow打到根节点上
|
|
2004
|
+
if (mode === 'ali' && !options.hasVirtualHost) processFlag = el === root
|
|
2005
|
+
if (options.isComponent && processFlag && isRealNode(el)) {
|
|
1942
2006
|
if (show !== undefined) {
|
|
1943
2007
|
show = `{{${parseMustache(show).result}&&mpxShow}}`
|
|
1944
2008
|
} else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const babylon = require('
|
|
2
|
-
const t = require('babel
|
|
3
|
-
const generate = require('babel
|
|
1
|
+
const babylon = require('@babel/parser')
|
|
2
|
+
const t = require('@babel/types')
|
|
3
|
+
const generate = require('@babel/generator').default
|
|
4
4
|
const dash2hump = require('../utils/hump-dash').dash2hump
|
|
5
5
|
|
|
6
6
|
module.exports = function transDynamicClassExpr (expr) {
|
package/lib/wxs/wxs-loader.js
CHANGED
|
@@ -17,6 +17,7 @@ module.exports = function () {
|
|
|
17
17
|
const assetsInfo = mpx.assetsInfo
|
|
18
18
|
const mode = mpx.mode
|
|
19
19
|
const wxsMap = mpx.wxsMap
|
|
20
|
+
const getOutputPath = mpx.getOutputPath
|
|
20
21
|
const rootName = mainCompilation._preparedEntrypoints[0].name
|
|
21
22
|
let { resourcePath, queryObj } = parseRequest(this.resource)
|
|
22
23
|
const { resourcePath: issuerResourcePath, queryObj: issuerQueryObj } = parseRequest(queryObj.issuerResource || this._module.issuer.resource)
|
|
@@ -36,9 +37,9 @@ module.exports = function () {
|
|
|
36
37
|
if (wxsModule) {
|
|
37
38
|
resourcePath = `${resourcePath}~${wxsModule}`
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
let filename = path.join(
|
|
40
|
+
const packageRoot = queryObj.packageRoot || ''
|
|
41
|
+
const ext = config[mode].wxs.ext
|
|
42
|
+
let filename = toPosix(path.join(packageRoot, getOutputPath(resourcePath, ext.slice(1), { ext })))
|
|
42
43
|
|
|
43
44
|
filename = mpx.getPackageInfo({
|
|
44
45
|
resource: this.resource,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const babylon = require('
|
|
2
|
-
const traverse = require('babel
|
|
3
|
-
const t = require('babel
|
|
4
|
-
const generate = require('babel
|
|
1
|
+
const babylon = require('@babel/parser')
|
|
2
|
+
const traverse = require('@babel/traverse').default
|
|
3
|
+
const t = require('@babel/types')
|
|
4
|
+
const generate = require('@babel/generator').default
|
|
5
5
|
const getMainCompilation = require('../utils/get-main-compilation')
|
|
6
6
|
const parseRequest = require('../utils/parse-request')
|
|
7
7
|
const isEmptyObject = require('../utils/is-empty-object')
|
package/lib/wxss/processCss.js
CHANGED
|
@@ -3,37 +3,37 @@
|
|
|
3
3
|
Author Tobias Koppers @sokra
|
|
4
4
|
Modified by @hiyuki
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const formatCodeFrame = require('@babel/code-frame')
|
|
7
|
+
const Tokenizer = require('css-selector-tokenizer')
|
|
8
|
+
const postcss = require('postcss')
|
|
9
|
+
const loaderUtils = require('loader-utils')
|
|
10
|
+
const assign = require('object-assign')
|
|
11
|
+
const getLocalIdent = require('./getLocalIdent')
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const icssUtils = require('icss-utils')
|
|
14
|
+
const localByDefault = require('postcss-modules-local-by-default')
|
|
15
|
+
const extractImports = require('postcss-modules-extract-imports')
|
|
16
|
+
const modulesScope = require('postcss-modules-scope')
|
|
17
|
+
const modulesValues = require('postcss-modules-values')
|
|
18
|
+
const valueParser = require('postcss-value-parser')
|
|
19
|
+
const isUrlRequest = require('../utils/is-url-request')
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const parserPlugin = postcss.plugin('css-loader-parser', function (options) {
|
|
22
22
|
return function (css) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const imports = {}
|
|
24
|
+
let exports = {}
|
|
25
|
+
const importItems = []
|
|
26
|
+
const urlItems = []
|
|
27
27
|
|
|
28
28
|
function replaceImportsInString (str) {
|
|
29
29
|
if (options.import) {
|
|
30
|
-
|
|
30
|
+
const tokens = valueParser(str)
|
|
31
31
|
tokens.walk(function (node) {
|
|
32
32
|
if (node.type !== 'word') {
|
|
33
33
|
return
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const token = node.value
|
|
36
|
+
const importIndex = imports['$' + token]
|
|
37
37
|
if (typeof importIndex === 'number') {
|
|
38
38
|
node.value = '___CSS_LOADER_IMPORT___' + importIndex + '___'
|
|
39
39
|
}
|
|
@@ -45,8 +45,8 @@ var parserPlugin = postcss.plugin('css-loader-parser', function (options) {
|
|
|
45
45
|
|
|
46
46
|
if (options.import) {
|
|
47
47
|
css.walkAtRules(/^import$/i, function (rule) {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const values = Tokenizer.parseValues(rule.params)
|
|
49
|
+
let url = values.nodes[0].nodes[0]
|
|
50
50
|
if (url && url.type === 'url') {
|
|
51
51
|
url = url.url
|
|
52
52
|
} else if (url && url.type === 'string') {
|
|
@@ -56,7 +56,7 @@ var parserPlugin = postcss.plugin('css-loader-parser', function (options) {
|
|
|
56
56
|
return
|
|
57
57
|
}
|
|
58
58
|
values.nodes[0].nodes.shift()
|
|
59
|
-
|
|
59
|
+
const mediaQuery = Tokenizer.stringifyValues(values)
|
|
60
60
|
|
|
61
61
|
if (isUrlRequest(url, options.root)) {
|
|
62
62
|
url = loaderUtils.urlToRequest(url, options.root)
|
|
@@ -70,10 +70,10 @@ var parserPlugin = postcss.plugin('css-loader-parser', function (options) {
|
|
|
70
70
|
})
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
const icss = icssUtils.extractICSS(css)
|
|
74
74
|
exports = icss.icssExports
|
|
75
75
|
Object.keys(icss.icssImports).forEach(function (key) {
|
|
76
|
-
|
|
76
|
+
const url = loaderUtils.parseString(key)
|
|
77
77
|
Object.keys(icss.icssImports[key]).forEach(function (prop) {
|
|
78
78
|
imports['$' + prop] = importItems.length
|
|
79
79
|
importItems.push({
|
|
@@ -101,7 +101,7 @@ var parserPlugin = postcss.plugin('css-loader-parser', function (options) {
|
|
|
101
101
|
item.nodes.forEach(processNode)
|
|
102
102
|
break
|
|
103
103
|
case 'item':
|
|
104
|
-
|
|
104
|
+
const importIndex = imports['$' + item.name]
|
|
105
105
|
if (typeof importIndex === 'number') {
|
|
106
106
|
item.name = '___CSS_LOADER_IMPORT___' + importIndex + '___'
|
|
107
107
|
}
|
|
@@ -112,7 +112,7 @@ var parserPlugin = postcss.plugin('css-loader-parser', function (options) {
|
|
|
112
112
|
item.stringType = ''
|
|
113
113
|
delete item.innerSpacingBefore
|
|
114
114
|
delete item.innerSpacingAfter
|
|
115
|
-
|
|
115
|
+
const url = item.url
|
|
116
116
|
item.url = '___CSS_LOADER_URL___' + urlItems.length + '___'
|
|
117
117
|
urlItems.push({
|
|
118
118
|
url: url
|
|
@@ -123,7 +123,7 @@ var parserPlugin = postcss.plugin('css-loader-parser', function (options) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
css.walkDecls(function (decl) {
|
|
126
|
-
|
|
126
|
+
const values = Tokenizer.parseValues(decl.value)
|
|
127
127
|
values.nodes.forEach(function (value) {
|
|
128
128
|
value.nodes.forEach(processNode)
|
|
129
129
|
})
|
|
@@ -142,17 +142,17 @@ var parserPlugin = postcss.plugin('css-loader-parser', function (options) {
|
|
|
142
142
|
})
|
|
143
143
|
|
|
144
144
|
module.exports = function processCss (inputSource, inputMap, options, callback) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
const query = options.query
|
|
146
|
+
const root = query.root && query.root.length > 0 ? query.root.replace(/\/$/, '') : query.root
|
|
147
|
+
const context = query.context
|
|
148
|
+
const localIdentName = query.localIdentName || '[hash:base64]'
|
|
149
|
+
const localIdentRegExp = query.localIdentRegExp
|
|
150
|
+
const forceMinimize = query.minimize
|
|
151
|
+
const minimize = typeof forceMinimize !== 'undefined' ? !!forceMinimize : options.minimize
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
const customGetLocalIdent = query.getLocalIdent || getLocalIdent
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
const parserOptions = {
|
|
156
156
|
root: root,
|
|
157
157
|
mode: options.mode,
|
|
158
158
|
url: query.url !== false,
|
|
@@ -160,7 +160,7 @@ module.exports = function processCss (inputSource, inputMap, options, callback)
|
|
|
160
160
|
resolve: options.resolve
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
const pipeline = postcss([
|
|
164
164
|
modulesValues,
|
|
165
165
|
localByDefault({
|
|
166
166
|
mode: options.mode,
|
|
@@ -192,8 +192,8 @@ module.exports = function processCss (inputSource, inputMap, options, callback)
|
|
|
192
192
|
])
|
|
193
193
|
|
|
194
194
|
if (minimize) {
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
const cssnano = require('cssnano')
|
|
196
|
+
const minimizeOptions = assign({}, query.minimize);
|
|
197
197
|
['zindex', 'normalizeUrl', 'discardUnused', 'mergeIdents', 'reduceIdents', 'autoprefixer', 'svgo'].forEach(function (name) {
|
|
198
198
|
if (typeof minimizeOptions[name] === 'undefined') {
|
|
199
199
|
minimizeOptions[name] = false
|
|
@@ -226,7 +226,7 @@ module.exports = function processCss (inputSource, inputMap, options, callback)
|
|
|
226
226
|
})
|
|
227
227
|
}).catch(function (err) {
|
|
228
228
|
if (err.name === 'CssSyntaxError') {
|
|
229
|
-
|
|
229
|
+
const wrappedError = new CSSLoaderError(
|
|
230
230
|
'Syntax Error',
|
|
231
231
|
err.reason,
|
|
232
232
|
err.line != null && err.column != null
|
|
@@ -242,7 +242,7 @@ module.exports = function processCss (inputSource, inputMap, options, callback)
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
function formatMessage (message, loc, source) {
|
|
245
|
-
|
|
245
|
+
let formatted = message
|
|
246
246
|
if (loc) {
|
|
247
247
|
formatted = formatted +
|
|
248
248
|
' (' + loc.line + ':' + loc.column + ')'
|
|
@@ -260,7 +260,7 @@ function CSSLoaderError (name, message, loc, source, error) {
|
|
|
260
260
|
this.name = name
|
|
261
261
|
this.error = error
|
|
262
262
|
this.message = formatMessage(message, loc, source)
|
|
263
|
-
this.
|
|
263
|
+
this.message = formatMessage(message, loc, source)
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
CSSLoaderError.prototype = Object.create(Error.prototype)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.109",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"lib"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@babel/code-frame": "^7.16.0",
|
|
19
|
+
"@babel/generator": "^7.16.0",
|
|
20
|
+
"@babel/parser": "^7.16.2",
|
|
21
|
+
"@babel/traverse": "^7.16.0",
|
|
22
|
+
"@babel/types": "^7.16.0",
|
|
18
23
|
"@better-scroll/core": "^2.2.1",
|
|
19
24
|
"@better-scroll/movable": "^2.2.1",
|
|
20
25
|
"@better-scroll/observe-dom": "^2.2.1",
|
|
@@ -24,11 +29,6 @@
|
|
|
24
29
|
"@better-scroll/zoom": "^2.2.1",
|
|
25
30
|
"acorn-walk": "^7.2.0",
|
|
26
31
|
"async": "^2.6.0",
|
|
27
|
-
"babel-code-frame": "^6.26.0",
|
|
28
|
-
"babel-generator": "^6.26.1",
|
|
29
|
-
"babel-traverse": "^6.26.0",
|
|
30
|
-
"babel-types": "^6.26.0",
|
|
31
|
-
"babylon": "^6.18.0",
|
|
32
32
|
"consolidate": "^0.15.1",
|
|
33
33
|
"css": "^2.2.1",
|
|
34
34
|
"css-selector-tokenizer": "^0.7.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"@types/babel-traverse": "^6.25.4",
|
|
82
82
|
"@types/babel-types": "^7.0.4"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "1531292ee192d1af4d84e8aac8fa02afe5d92e24"
|
|
85
85
|
}
|