@mpxjs/webpack-plugin 2.7.53 → 2.7.55
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 +2 -2
- package/lib/loader.js +4 -5
- package/lib/runtime/animation.js +59 -0
- package/lib/runtime/optionProcessor.js +9 -100
- package/lib/runtime/transRpxStyle.js +44 -0
- package/lib/web/processJSON.js +1 -3
- package/lib/web/processScript.js +8 -4
- package/lib/wxss/CssSyntaxError.js +29 -0
- package/lib/wxss/Warning.js +22 -0
- package/lib/wxss/index.js +5 -0
- package/lib/wxss/loader.js +233 -131
- package/lib/wxss/options.json +209 -0
- package/lib/wxss/plugins/index.js +5 -0
- package/lib/wxss/plugins/postcss-icss-parser.js +124 -0
- package/lib/wxss/plugins/postcss-import-parser.js +372 -0
- package/lib/wxss/plugins/postcss-url-parser.js +447 -0
- package/lib/wxss/runtime/api.js +104 -0
- package/lib/wxss/runtime/getUrl.js +28 -0
- package/lib/wxss/runtime/noSourceMaps.js +1 -0
- package/lib/wxss/runtime/sourceMaps.js +25 -0
- package/lib/wxss/utils.js +1313 -0
- package/package.json +2 -2
- package/lib/wxss/compile-exports.js +0 -52
- package/lib/wxss/createResolver.js +0 -36
- package/lib/wxss/css-base.js +0 -79
- package/lib/wxss/getLocalIdent.js +0 -24
- package/lib/wxss/localsLoader.js +0 -44
- package/lib/wxss/processCss.js +0 -271
- package/lib/wxss/url/escape.js +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.55",
|
|
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": "988b3f83c36ba5280ee7d050fc8b610ae4f3ad86"
|
|
84
84
|
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var camelCase = require('lodash.camelcase')
|
|
2
|
-
|
|
3
|
-
function dashesCamelCase (str) {
|
|
4
|
-
return str.replace(/-+(\w)/g, function (match, firstLetter) {
|
|
5
|
-
return firstLetter.toUpperCase()
|
|
6
|
-
})
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = function compileExports (result, importItemMatcher, camelCaseKeys) {
|
|
10
|
-
if (!Object.keys(result.exports).length) {
|
|
11
|
-
return ''
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var exportJs = Object.keys(result.exports).reduce(function (res, key) {
|
|
15
|
-
var valueAsString = JSON.stringify(result.exports[key])
|
|
16
|
-
valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher)
|
|
17
|
-
|
|
18
|
-
function addEntry (k) {
|
|
19
|
-
res.push('\t' + JSON.stringify(k) + ': ' + valueAsString)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var targetKey
|
|
23
|
-
switch (camelCaseKeys) {
|
|
24
|
-
case true:
|
|
25
|
-
addEntry(key)
|
|
26
|
-
targetKey = camelCase(key)
|
|
27
|
-
if (targetKey !== key) {
|
|
28
|
-
addEntry(targetKey)
|
|
29
|
-
}
|
|
30
|
-
break
|
|
31
|
-
case 'dashes':
|
|
32
|
-
addEntry(key)
|
|
33
|
-
targetKey = dashesCamelCase(key)
|
|
34
|
-
if (targetKey !== key) {
|
|
35
|
-
addEntry(targetKey)
|
|
36
|
-
}
|
|
37
|
-
break
|
|
38
|
-
case 'only':
|
|
39
|
-
addEntry(camelCase(key))
|
|
40
|
-
break
|
|
41
|
-
case 'dashesOnly':
|
|
42
|
-
addEntry(dashesCamelCase(key))
|
|
43
|
-
break
|
|
44
|
-
default:
|
|
45
|
-
addEntry(key)
|
|
46
|
-
break
|
|
47
|
-
}
|
|
48
|
-
return res
|
|
49
|
-
}, []).join(',\n')
|
|
50
|
-
|
|
51
|
-
return '{\n' + exportJs + '\n}'
|
|
52
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module.exports = function createResolver (alias) {
|
|
2
|
-
if (typeof alias !== 'object' || Array.isArray(alias)) {
|
|
3
|
-
return function (url) {
|
|
4
|
-
return url
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
alias = Object.keys(alias).map(function (key) {
|
|
9
|
-
var onlyModule = false
|
|
10
|
-
var obj = alias[key]
|
|
11
|
-
if (/\$$/.test(key)) {
|
|
12
|
-
onlyModule = true
|
|
13
|
-
key = key.substr(0, key.length - 1)
|
|
14
|
-
}
|
|
15
|
-
if (typeof obj === 'string') {
|
|
16
|
-
obj = {
|
|
17
|
-
alias: obj
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
obj = Object.assign({
|
|
21
|
-
name: key,
|
|
22
|
-
onlyModule: onlyModule
|
|
23
|
-
}, obj)
|
|
24
|
-
return obj
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return function (url) {
|
|
28
|
-
alias.forEach(function (obj) {
|
|
29
|
-
var name = obj.name
|
|
30
|
-
if (url === name || (!obj.onlyModule && url.startsWith(name + '/'))) {
|
|
31
|
-
url = obj.alias + url.substr(name.length)
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
return url
|
|
35
|
-
}
|
|
36
|
-
}
|
package/lib/wxss/css-base.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
Modified by @hiyuki
|
|
5
|
-
*/
|
|
6
|
-
// css base code, injected by the css-loader
|
|
7
|
-
module.exports = function (useSourceMap) {
|
|
8
|
-
var list = []
|
|
9
|
-
|
|
10
|
-
// return the list of modules as css string
|
|
11
|
-
list.toString = function toString () {
|
|
12
|
-
return this.map(function (item) {
|
|
13
|
-
var content = cssWithMappingToString(item, useSourceMap)
|
|
14
|
-
if (item[2]) {
|
|
15
|
-
return '@media ' + item[2] + '{' + content + '}'
|
|
16
|
-
} else {
|
|
17
|
-
return content
|
|
18
|
-
}
|
|
19
|
-
}).join('')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// import a list of modules into the list
|
|
23
|
-
list.i = function (modules, mediaQuery) {
|
|
24
|
-
if (typeof modules === 'string') {
|
|
25
|
-
modules = [[null, modules, '']]
|
|
26
|
-
}
|
|
27
|
-
var alreadyImportedModules = {}
|
|
28
|
-
for (var i = 0; i < this.length; i++) {
|
|
29
|
-
var id = this[i][0]
|
|
30
|
-
if (typeof id === 'number') {
|
|
31
|
-
alreadyImportedModules[id] = true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
for (i = 0; i < modules.length; i++) {
|
|
35
|
-
var item = modules[i]
|
|
36
|
-
// skip already imported module
|
|
37
|
-
// this implementation is not 100% perfect for weird media query combinations
|
|
38
|
-
// when a module is imported multiple times with different media queries.
|
|
39
|
-
// I hope this will never occur (Hey this way we have smaller bundles)
|
|
40
|
-
if (typeof item[0] !== 'number' || !alreadyImportedModules[item[0]]) {
|
|
41
|
-
if (mediaQuery && !item[2]) {
|
|
42
|
-
item[2] = mediaQuery
|
|
43
|
-
} else if (mediaQuery) {
|
|
44
|
-
item[2] = '(' + item[2] + ') and (' + mediaQuery + ')'
|
|
45
|
-
}
|
|
46
|
-
list.push(item)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return list
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function cssWithMappingToString (item, useSourceMap) {
|
|
54
|
-
var content = item[1] || ''
|
|
55
|
-
var cssMapping = item[3]
|
|
56
|
-
if (!cssMapping) {
|
|
57
|
-
return content
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (useSourceMap && typeof btoa === 'function') {
|
|
61
|
-
var sourceMapping = toComment(cssMapping)
|
|
62
|
-
var sourceURLs = cssMapping.sources.map(function (source) {
|
|
63
|
-
return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n')
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return [content].join('\n')
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Adapted from convert-source-map (MIT)
|
|
73
|
-
function toComment (sourceMap) {
|
|
74
|
-
// eslint-disable-next-line no-undef
|
|
75
|
-
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))
|
|
76
|
-
var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64
|
|
77
|
-
|
|
78
|
-
return '/*# ' + data + ' */'
|
|
79
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
Modified by @hiyuki
|
|
5
|
-
*/
|
|
6
|
-
var loaderUtils = require('loader-utils')
|
|
7
|
-
var path = require('path')
|
|
8
|
-
|
|
9
|
-
module.exports = function getLocalIdent (loaderContext, localIdentName, localName, options) {
|
|
10
|
-
if (!options.context) {
|
|
11
|
-
if (loaderContext.rootContext) {
|
|
12
|
-
options.context = loaderContext.rootContext
|
|
13
|
-
} else if (loaderContext.options && typeof loaderContext.options.context === 'string') {
|
|
14
|
-
options.context = loaderContext.options.context
|
|
15
|
-
} else {
|
|
16
|
-
options.context = loaderContext.context
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
var request = path.relative(options.context, loaderContext.resourcePath)
|
|
20
|
-
options.content = options.hashPrefix + request + '+' + localName
|
|
21
|
-
localIdentName = localIdentName.replace(/\[local\]/gi, localName)
|
|
22
|
-
var hash = loaderUtils.interpolateName(loaderContext, localIdentName, options)
|
|
23
|
-
return hash.replace(new RegExp('[^a-zA-Z0-9\\-_\u00A0-\uFFFF]', 'g'), '-').replace(/^((-?[0-9])|--)/, '_$1')
|
|
24
|
-
}
|
package/lib/wxss/localsLoader.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
Modified by @hiyuki
|
|
5
|
-
*/
|
|
6
|
-
var loaderUtils = require('loader-utils')
|
|
7
|
-
var processCss = require('./processCss')
|
|
8
|
-
var compileExports = require('./compile-exports')
|
|
9
|
-
var createResolver = require('./createResolver')
|
|
10
|
-
|
|
11
|
-
module.exports = function (content) {
|
|
12
|
-
if (this.cacheable) this.cacheable()
|
|
13
|
-
var callback = this.async()
|
|
14
|
-
var query = loaderUtils.getOptions(this) || {}
|
|
15
|
-
var moduleMode = query.modules || query.module
|
|
16
|
-
var camelCaseKeys = query.camelCase || query.camelcase
|
|
17
|
-
var resolve = createResolver(query.alias)
|
|
18
|
-
|
|
19
|
-
processCss(content, null, {
|
|
20
|
-
mode: moduleMode ? 'local' : 'global',
|
|
21
|
-
query: query,
|
|
22
|
-
minimize: this.minimize,
|
|
23
|
-
loaderContext: this,
|
|
24
|
-
resolve: resolve
|
|
25
|
-
}, function (err, result) {
|
|
26
|
-
if (err) return callback(err)
|
|
27
|
-
|
|
28
|
-
function importItemMatcher (item) {
|
|
29
|
-
var match = result.importItemRegExp.exec(item)
|
|
30
|
-
var idx = +match[1]
|
|
31
|
-
var importItem = result.importItems[idx]
|
|
32
|
-
var importUrl = importItem.url
|
|
33
|
-
return '" + require(' + loaderUtils.stringifyRequest(this, importUrl) + ')' +
|
|
34
|
-
'[' + JSON.stringify(importItem.export) + '] + "'
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var exportJs = compileExports(result, importItemMatcher.bind(this), camelCaseKeys)
|
|
38
|
-
if (exportJs) {
|
|
39
|
-
exportJs = 'module.exports = ' + exportJs + ';'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
callback(null, exportJs)
|
|
43
|
-
}.bind(this))
|
|
44
|
-
}
|
package/lib/wxss/processCss.js
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
Modified by @hiyuki
|
|
5
|
-
*/
|
|
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
|
-
|
|
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
|
-
// css-loader-parser
|
|
21
|
-
|
|
22
|
-
const parserPlugin = function (options) {
|
|
23
|
-
return {
|
|
24
|
-
postcssPlugin: 'css-loader-parser',
|
|
25
|
-
Once (css) {
|
|
26
|
-
const imports = {}
|
|
27
|
-
let exports = {}
|
|
28
|
-
const importItems = []
|
|
29
|
-
const urlItems = []
|
|
30
|
-
|
|
31
|
-
function replaceImportsInString (str) {
|
|
32
|
-
if (options.import) {
|
|
33
|
-
const tokens = valueParser(str)
|
|
34
|
-
tokens.walk(function (node) {
|
|
35
|
-
if (node.type !== 'word') {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
const token = node.value
|
|
39
|
-
const importIndex = imports['$' + token]
|
|
40
|
-
if (typeof importIndex === 'number') {
|
|
41
|
-
node.value = '___CSS_LOADER_IMPORT___' + importIndex + '___'
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
return tokens.toString()
|
|
45
|
-
}
|
|
46
|
-
return str
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (options.import) {
|
|
50
|
-
css.walkAtRules(/^import$/i, function (rule) {
|
|
51
|
-
const values = Tokenizer.parseValues(rule.params)
|
|
52
|
-
let url = values.nodes[0].nodes[0]
|
|
53
|
-
if (url && url.type === 'url') {
|
|
54
|
-
url = url.url
|
|
55
|
-
} else if (url && url.type === 'string') {
|
|
56
|
-
url = url.value
|
|
57
|
-
} else throw rule.error('Unexpected format ' + rule.params)
|
|
58
|
-
if (!url.replace(/\s/g, '').length) {
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
values.nodes[0].nodes.shift()
|
|
62
|
-
const mediaQuery = Tokenizer.stringifyValues(values)
|
|
63
|
-
|
|
64
|
-
if (isUrlRequest(url, options.root)) {
|
|
65
|
-
url = loaderUtils.urlToRequest(url, options.root)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
importItems.push({
|
|
69
|
-
url: url,
|
|
70
|
-
mediaQuery: mediaQuery
|
|
71
|
-
})
|
|
72
|
-
rule.remove()
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const icss = icssUtils.extractICSS(css)
|
|
77
|
-
exports = icss.icssExports
|
|
78
|
-
Object.keys(icss.icssImports).forEach(function (key) {
|
|
79
|
-
const url = loaderUtils.parseString(key)
|
|
80
|
-
Object.keys(icss.icssImports[key]).forEach(function (prop) {
|
|
81
|
-
imports['$' + prop] = importItems.length
|
|
82
|
-
importItems.push({
|
|
83
|
-
url: url,
|
|
84
|
-
export: icss.icssImports[key][prop]
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
Object.keys(exports).forEach(function (exportName) {
|
|
90
|
-
exports[exportName] = replaceImportsInString(exports[exportName])
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
function isAlias (url) {
|
|
94
|
-
// Handle alias starting by / and root disabled
|
|
95
|
-
return url !== options.resolve(url)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function processNode (item) {
|
|
99
|
-
switch (item.type) {
|
|
100
|
-
case 'value':
|
|
101
|
-
item.nodes.forEach(processNode)
|
|
102
|
-
break
|
|
103
|
-
case 'nested-item':
|
|
104
|
-
item.nodes.forEach(processNode)
|
|
105
|
-
break
|
|
106
|
-
case 'item':
|
|
107
|
-
const importIndex = imports['$' + item.name]
|
|
108
|
-
if (typeof importIndex === 'number') {
|
|
109
|
-
item.name = '___CSS_LOADER_IMPORT___' + importIndex + '___'
|
|
110
|
-
}
|
|
111
|
-
break
|
|
112
|
-
case 'url':
|
|
113
|
-
if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && (isAlias(item.url) || isUrlRequest(item.url, options.root))) {
|
|
114
|
-
// Strip quotes, they will be re-added if the module needs them
|
|
115
|
-
item.stringType = ''
|
|
116
|
-
delete item.innerSpacingBefore
|
|
117
|
-
delete item.innerSpacingAfter
|
|
118
|
-
const url = item.url
|
|
119
|
-
item.url = '___CSS_LOADER_URL___' + urlItems.length + '___'
|
|
120
|
-
urlItems.push({
|
|
121
|
-
url: url
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
break
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
css.walkDecls(function (decl) {
|
|
129
|
-
const values = Tokenizer.parseValues(decl.value)
|
|
130
|
-
values.nodes.forEach(function (value) {
|
|
131
|
-
value.nodes.forEach(processNode)
|
|
132
|
-
})
|
|
133
|
-
decl.value = Tokenizer.stringifyValues(values)
|
|
134
|
-
})
|
|
135
|
-
css.walkAtRules(function (atrule) {
|
|
136
|
-
if (typeof atrule.params === 'string') {
|
|
137
|
-
atrule.params = replaceImportsInString(atrule.params)
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
options.importItems = importItems
|
|
142
|
-
options.urlItems = urlItems
|
|
143
|
-
options.exports = exports
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
module.exports = function processCss (inputSource, inputMap, options, callback) {
|
|
149
|
-
const query = options.query
|
|
150
|
-
const root = query.root && query.root.length > 0 ? query.root.replace(/\/$/, '') : query.root
|
|
151
|
-
const context = query.context
|
|
152
|
-
const localIdentName = query.localIdentName || '[hash:base64]'
|
|
153
|
-
const localIdentRegExp = query.localIdentRegExp
|
|
154
|
-
const forceMinimize = query.minimize
|
|
155
|
-
const minimize = typeof forceMinimize !== 'undefined' ? !!forceMinimize : options.minimize
|
|
156
|
-
|
|
157
|
-
const customGetLocalIdent = query.getLocalIdent || getLocalIdent
|
|
158
|
-
|
|
159
|
-
const parserOptions = {
|
|
160
|
-
root: root,
|
|
161
|
-
mode: options.mode,
|
|
162
|
-
url: query.url !== false,
|
|
163
|
-
import: query.import !== false,
|
|
164
|
-
resolve: options.resolve
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const pipeline = postcss([
|
|
168
|
-
modulesValues,
|
|
169
|
-
localByDefault({
|
|
170
|
-
mode: options.mode,
|
|
171
|
-
rewriteUrl: function (global, url) {
|
|
172
|
-
if (parserOptions.url) {
|
|
173
|
-
url = url.trim()
|
|
174
|
-
|
|
175
|
-
if (!url.replace(/\s/g, '').length || !isUrlRequest(url, root)) {
|
|
176
|
-
return url
|
|
177
|
-
}
|
|
178
|
-
if (global) {
|
|
179
|
-
return loaderUtils.urlToRequest(url, root)
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return url
|
|
183
|
-
}
|
|
184
|
-
}),
|
|
185
|
-
extractImports(),
|
|
186
|
-
modulesScope({
|
|
187
|
-
generateScopedName: function generateScopedName (exportName) {
|
|
188
|
-
return customGetLocalIdent(options.loaderContext, localIdentName, exportName, {
|
|
189
|
-
regExp: localIdentRegExp,
|
|
190
|
-
hashPrefix: query.hashPrefix || '',
|
|
191
|
-
context: context
|
|
192
|
-
})
|
|
193
|
-
}
|
|
194
|
-
}),
|
|
195
|
-
parserPlugin(parserOptions)
|
|
196
|
-
])
|
|
197
|
-
|
|
198
|
-
if (minimize) {
|
|
199
|
-
const cssnano = require('cssnano')
|
|
200
|
-
const minimizeOptions = assign({}, query.minimize);
|
|
201
|
-
['zindex', 'normalizeUrl', 'discardUnused', 'mergeIdents', 'reduceIdents', 'autoprefixer', 'svgo'].forEach(function (name) {
|
|
202
|
-
if (typeof minimizeOptions[name] === 'undefined') {
|
|
203
|
-
minimizeOptions[name] = false
|
|
204
|
-
}
|
|
205
|
-
})
|
|
206
|
-
pipeline.use(cssnano(minimizeOptions))
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
pipeline.process(inputSource, {
|
|
210
|
-
// we need a prefix to avoid path rewriting of PostCSS
|
|
211
|
-
from: '/css-loader!' + options.from,
|
|
212
|
-
to: options.to,
|
|
213
|
-
map: options.sourceMap ? {
|
|
214
|
-
prev: inputMap,
|
|
215
|
-
sourcesContent: true,
|
|
216
|
-
inline: false,
|
|
217
|
-
annotation: false
|
|
218
|
-
} : null
|
|
219
|
-
}).then(function (result) {
|
|
220
|
-
callback(null, {
|
|
221
|
-
source: result.css,
|
|
222
|
-
map: result.map && result.map.toJSON(),
|
|
223
|
-
exports: parserOptions.exports,
|
|
224
|
-
importItems: parserOptions.importItems,
|
|
225
|
-
importItemRegExpG: /___CSS_LOADER_IMPORT___([0-9]+)___/g,
|
|
226
|
-
importItemRegExp: /___CSS_LOADER_IMPORT___([0-9]+)___/,
|
|
227
|
-
urlItems: parserOptions.urlItems,
|
|
228
|
-
urlItemRegExpG: /___CSS_LOADER_URL___([0-9]+)___/g,
|
|
229
|
-
urlItemRegExp: /___CSS_LOADER_URL___([0-9]+)___/
|
|
230
|
-
})
|
|
231
|
-
}).catch(function (err) {
|
|
232
|
-
if (err.name === 'CssSyntaxError') {
|
|
233
|
-
const wrappedError = new CSSLoaderError(
|
|
234
|
-
'Syntax Error',
|
|
235
|
-
err.reason,
|
|
236
|
-
err.line != null && err.column != null
|
|
237
|
-
? { line: err.line, column: err.column }
|
|
238
|
-
: null,
|
|
239
|
-
err.input.source
|
|
240
|
-
)
|
|
241
|
-
callback(wrappedError)
|
|
242
|
-
} else {
|
|
243
|
-
callback(err)
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function formatMessage (message, loc, source) {
|
|
249
|
-
let formatted = message
|
|
250
|
-
if (loc) {
|
|
251
|
-
formatted = formatted +
|
|
252
|
-
' (' + loc.line + ':' + loc.column + ')'
|
|
253
|
-
}
|
|
254
|
-
if (loc && source) {
|
|
255
|
-
formatted = formatted +
|
|
256
|
-
'\n\n' + formatCodeFrame(source, loc.line, loc.column) + '\n'
|
|
257
|
-
}
|
|
258
|
-
return formatted
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function CSSLoaderError (name, message, loc, source, error) {
|
|
262
|
-
Error.call(this)
|
|
263
|
-
Error.captureStackTrace(this, CSSLoaderError)
|
|
264
|
-
this.name = name
|
|
265
|
-
this.error = error
|
|
266
|
-
this.message = formatMessage(message, loc, source)
|
|
267
|
-
this.message = formatMessage(message, loc, source)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
CSSLoaderError.prototype = Object.create(Error.prototype)
|
|
271
|
-
CSSLoaderError.prototype.constructor = CSSLoaderError
|
package/lib/wxss/url/escape.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = function escape (url) {
|
|
2
|
-
if (typeof url !== 'string') {
|
|
3
|
-
return url
|
|
4
|
-
}
|
|
5
|
-
// If url is already wrapped in quotes, remove them
|
|
6
|
-
if (/^['"].*['"]$/.test(url)) {
|
|
7
|
-
url = url.slice(1, -1)
|
|
8
|
-
}
|
|
9
|
-
// Should url be wrapped?
|
|
10
|
-
// See https://drafts.csswg.org/css-values-3/#urls
|
|
11
|
-
if (/["'() \t\n]/.test(url)) {
|
|
12
|
-
return '"' + url.replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return url
|
|
16
|
-
}
|