File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 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')
33var selectorPath = require . resolve ( './selector' )
44var parserPath = require . resolve ( './parser' )
55var hash = require ( 'hash-sum' )
6+ var path = require ( 'path' )
67
78var defaultLang = {
89 template : 'html' ,
@@ -29,7 +30,9 @@ module.exports = function (content) {
2930 var output = ''
3031 var options = this . options . vue || { }
3132 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 )
3336
3437 // respect user babel options
3538 if ( this . options . babel ) {
@@ -102,11 +105,12 @@ module.exports = function (content) {
102105 }
103106
104107 function getRewriter ( type , scoped ) {
108+ var meta = '?id=' + moduleId + '&file=' + fileName
105109 switch ( type ) {
106110 case 'template' :
107- return scoped ? ( rewriters . template + '?id=' + moduleId + '!' ) : ''
111+ return scoped ? ( rewriters . template + meta + '!' ) : ''
108112 case 'style' :
109- return rewriters . style + '?id=' + moduleId + ( scoped ? '&scoped=true!' : '!' )
113+ return rewriters . style + meta + ( scoped ? '&scoped=true!' : '!' )
110114 default :
111115 return ''
112116 }
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ module.exports = function (css, map) {
5656 }
5757
5858 // postcss options, for source maps
59- var file = loaderUtils . getRemainingRequest ( this )
59+ var file = this . resourcePath
6060 var opts
6161 opts = {
6262 from : file ,
@@ -74,7 +74,11 @@ module.exports = function (css, map) {
7474 postcss ( plugins )
7575 . process ( css , opts )
7676 . 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 )
7882 } )
7983 . catch ( function ( e ) {
8084 console . log ( e )
You can’t perform that action at this time.
0 commit comments