forked from zhurui/management
28 lines
637 B
JavaScript
28 lines
637 B
JavaScript
|
/**
|
||
|
* Translates the list format produced by css-loader into something
|
||
|
* easier to manipulate.
|
||
|
*/
|
||
|
export default function listToStyles (parentId, list) {
|
||
|
var styles = []
|
||
|
var newStyles = {}
|
||
|
for (var i = 0; i < list.length; i++) {
|
||
|
var item = list[i]
|
||
|
var id = item[0]
|
||
|
var css = item[1]
|
||
|
var media = item[2]
|
||
|
var sourceMap = item[3]
|
||
|
var part = {
|
||
|
id: parentId + ':' + i,
|
||
|
css: css,
|
||
|
media: media,
|
||
|
sourceMap: sourceMap
|
||
|
}
|
||
|
if (!newStyles[id]) {
|
||
|
styles.push(newStyles[id] = { id: id, parts: [part] })
|
||
|
} else {
|
||
|
newStyles[id].parts.push(part)
|
||
|
}
|
||
|
}
|
||
|
return styles
|
||
|
}
|