File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ var assign = require('object-assign')
3
3
var selectorPath = require . resolve ( './selector' )
4
4
var parserPath = require . resolve ( './parser' )
5
5
var hash = require ( 'hash-sum' )
6
+ var path = require ( 'path' )
6
7
7
8
var defaultLang = {
8
9
template : 'html' ,
@@ -29,7 +30,9 @@ module.exports = function (content) {
29
30
var output = ''
30
31
var options = this . options . vue || { }
31
32
var vueUrl = loaderUtils . getRemainingRequest ( this )
32
- var moduleId = '_v-' + hash ( this . resourcePath )
33
+ var filePath = this . resourcePath
34
+ var fileName = path . basename ( filePath )
35
+ var moduleId = '_v-' + hash ( filePath )
33
36
34
37
// respect user babel options
35
38
if ( this . options . babel ) {
@@ -102,11 +105,12 @@ module.exports = function (content) {
102
105
}
103
106
104
107
function getRewriter ( type , scoped ) {
108
+ var meta = '?id=' + moduleId + '&file=' + fileName
105
109
switch ( type ) {
106
110
case 'template' :
107
- return scoped ? ( rewriters . template + '?id=' + moduleId + '!' ) : ''
111
+ return scoped ? ( rewriters . template + meta + '!' ) : ''
108
112
case 'style' :
109
- return rewriters . style + '?id=' + moduleId + ( scoped ? '&scoped=true!' : '!' )
113
+ return rewriters . style + meta + ( scoped ? '&scoped=true!' : '!' )
110
114
default :
111
115
return ''
112
116
}
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ module.exports = function (css, map) {
56
56
}
57
57
58
58
// postcss options, for source maps
59
- var file = loaderUtils . getRemainingRequest ( this )
59
+ var file = this . resourcePath
60
60
var opts
61
61
opts = {
62
62
from : file ,
@@ -74,7 +74,11 @@ module.exports = function (css, map) {
74
74
postcss ( plugins )
75
75
. process ( css , opts )
76
76
. then ( function ( result ) {
77
- cb ( null , result . css , result . map )
77
+ var map = JSON . parse ( result . map . toString ( ) )
78
+ // ensure we give the style source a unique name
79
+ // so that Webpack doesn't get confused
80
+ map . sources [ 0 ] = query . file + '.style'
81
+ cb ( null , result . css , map )
78
82
} )
79
83
. catch ( function ( e ) {
80
84
console . log ( e )
You can’t perform that action at this time.
0 commit comments