You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
637 B

4 years ago
  1. /**
  2. * Translates the list format produced by css-loader into something
  3. * easier to manipulate.
  4. */
  5. export default function listToStyles (parentId, list) {
  6. var styles = []
  7. var newStyles = {}
  8. for (var i = 0; i < list.length; i++) {
  9. var item = list[i]
  10. var id = item[0]
  11. var css = item[1]
  12. var media = item[2]
  13. var sourceMap = item[3]
  14. var part = {
  15. id: parentId + ':' + i,
  16. css: css,
  17. media: media,
  18. sourceMap: sourceMap
  19. }
  20. if (!newStyles[id]) {
  21. styles.push(newStyles[id] = { id: id, parts: [part] })
  22. } else {
  23. newStyles[id].parts.push(part)
  24. }
  25. }
  26. return styles
  27. }