Skip to content

Commit

Permalink
fix: sort imports
Browse files Browse the repository at this point in the history
should prevent mini-css-extract-plugin errors
  • Loading branch information
KaelWD committed Oct 12, 2018
1 parent 8709816 commit 2d2fc2c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = function (content, sourceMap) {
})

const imports = []
const components = []
tags.forEach(tag => {
for (const matcher of options.match) {
const match = matcher(tag, {
Expand All @@ -38,18 +37,20 @@ module.exports = function (content, sourceMap) {
component
})
if (match) {
components.push(match[0])
imports.push(match[1])
imports.push(match)
break
}
}
})

imports.sort((a, b) => a[0] < b[0] ? -1 : (a[0] > b[0] ? 1 : 0))

if (imports.length) {
let newContent = '/* vuetify-loader */\n'
imports.forEach(i => {
newContent += i + '\n'
newContent += i[1] + '\n'
})
const components = imports.map(i => i[0])
newContent += `component.options.components = Object.assign({\n ${components.join(',\n ')}\n}, component.options.components)`

// Insert our modification before the HMR code
Expand Down

0 comments on commit 2d2fc2c

Please sign in to comment.