@mpxjs/webpack-plugin 2.6.105 → 2.6.107
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/index.js +19 -0
- package/lib/json-compiler/index.js +14 -14
- package/lib/loader.js +2 -0
- package/lib/plugin-loader.js +2 -2
- 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 -0
- package/lib/template-compiler/bind-this.js +4 -4
- package/lib/template-compiler/trans-dynamic-class-expr.js +3 -3
- package/lib/web/processScript.js +3 -1
- 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/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
|
@@ -38,6 +38,7 @@ module.exports = function (content) {
|
|
|
38
38
|
const localSrcMode = queryObj.mode
|
|
39
39
|
const srcMode = localSrcMode || globalSrcMode
|
|
40
40
|
const vueContentCache = mpx.vueContentCache
|
|
41
|
+
const webRouteMode = mpx.webConfig.routeMode || 'hash'
|
|
41
42
|
const autoScope = matchCondition(resourcePath, mpx.autoScopeRules)
|
|
42
43
|
|
|
43
44
|
// 支持资源query传入page或component支持页面/组件单独编译
|
|
@@ -244,6 +245,7 @@ module.exports = function (content) {
|
|
|
244
245
|
i18n,
|
|
245
246
|
componentGenerics,
|
|
246
247
|
projectRoot,
|
|
248
|
+
webRouteMode,
|
|
247
249
|
jsonConfig: jsonRes.jsonObj,
|
|
248
250
|
componentId: queryObj.componentId || '',
|
|
249
251
|
tabBarMap: jsonRes.tabBarMap,
|
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,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: {
|
|
@@ -12,6 +12,7 @@ export default function processOption (
|
|
|
12
12
|
componentGenerics,
|
|
13
13
|
genericsInfo,
|
|
14
14
|
mixin,
|
|
15
|
+
webRouteMode,
|
|
15
16
|
Vue,
|
|
16
17
|
VueRouter,
|
|
17
18
|
i18n
|
|
@@ -122,6 +123,7 @@ export default function processOption (
|
|
|
122
123
|
})
|
|
123
124
|
}
|
|
124
125
|
global.__mpxRouter = option.router = new VueRouter({
|
|
126
|
+
mode: webRouteMode,
|
|
125
127
|
routes: routes
|
|
126
128
|
})
|
|
127
129
|
global.__mpxRouter.stack = []
|
|
@@ -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,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/web/processScript.js
CHANGED
|
@@ -39,6 +39,7 @@ module.exports = function (script, options, callback) {
|
|
|
39
39
|
const genericsInfo = options.genericsInfo
|
|
40
40
|
const componentGenerics = options.componentGenerics
|
|
41
41
|
const forceDisableBuiltInLoader = options.forceDisableBuiltInLoader
|
|
42
|
+
const webRouteMode = options.webRouteMode
|
|
42
43
|
|
|
43
44
|
const emitWarning = (msg) => {
|
|
44
45
|
loaderContext.emitWarning(
|
|
@@ -254,7 +255,8 @@ module.exports = function (script, options, callback) {
|
|
|
254
255
|
${JSON.stringify(tabBarMap)},
|
|
255
256
|
${JSON.stringify(componentGenerics)},
|
|
256
257
|
${JSON.stringify(genericsInfo)},
|
|
257
|
-
getWxsMixin(wxsModules)
|
|
258
|
+
getWxsMixin(wxsModules),
|
|
259
|
+
${JSON.stringify(webRouteMode)}`
|
|
258
260
|
|
|
259
261
|
if (ctorType === 'app') {
|
|
260
262
|
content += `,
|
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.107",
|
|
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": "c5821595c58c2908d56de41e68f1462b949bf646"
|
|
85
85
|
}
|