File tree Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ var loaderUtils = require('loader-utils')
22var assign = require ( 'object-assign' )
33var selectorPath = require . resolve ( './selector' )
44var parserPath = require . resolve ( './parser' )
5+ var hash = require ( 'hash-sum' )
56
67var defaultLang = {
78 template : 'html' ,
@@ -28,6 +29,7 @@ module.exports = function (content) {
2829 var output = ''
2930 var options = this . options . vue || { }
3031 var vueUrl = loaderUtils . getRemainingRequest ( this )
32+ var moduleId = '_v-' + hash ( this . resourcePath )
3133
3234 // respect user babel options
3335 if ( this . options . babel ) {
@@ -98,9 +100,9 @@ module.exports = function (content) {
98100 function getRewriter ( type , scoped ) {
99101 switch ( type ) {
100102 case 'template' :
101- return scoped ? ( rewriters . template + '!' ) : ''
103+ return scoped ? ( rewriters . template + '?id=' + moduleId + ' !') : ''
102104 case 'style' :
103- return rewriters . style + ( scoped ? '? scoped=true!' : '!' )
105+ return rewriters . style + '?id=' + moduleId + ( scoped ? '& scoped=true!' : '!' )
104106 default :
105107 return ''
106108 }
Original file line number Diff line number Diff line change 11var postcss = require ( 'postcss' )
22var selectorParser = require ( 'postcss-selector-parser' )
3- var hash = require ( 'hash-sum' )
43var loaderUtils = require ( 'loader-utils' )
54var assign = require ( 'object-assign' )
65
@@ -71,7 +70,7 @@ module.exports = function (css, map) {
7170 opts . map . prev = map
7271 }
7372
74- currentId = '_v-' + hash ( this . resourcePath )
73+ currentId = query . id
7574 postcss ( plugins )
7675 . process ( css , opts )
7776 . then ( function ( result ) {
Original file line number Diff line number Diff line change 11var parse5 = require ( 'parse5' )
22var parser = new parse5 . Parser ( )
33var serializer = new parse5 . Serializer ( )
4- var hash = require ( 'hash-sum ' )
4+ var loaderUtils = require ( 'loader-utils ' )
55
66module . exports = function ( html ) {
77 this . cacheable ( )
8- var id = '_v-' + hash ( this . resourcePath )
8+ var query = loaderUtils . parseQuery ( this . query )
9+ var id = query . id
910 var tree = parser . parseFragment ( html )
1011 walk ( tree , function ( node ) {
1112 if ( node . attrs ) {
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ describe('vue-loader', function () {
115115 var styles = window . document . querySelectorAll ( 'style' )
116116 expect ( styles [ 0 ] . textContent ) . to . contain ( 'h1 { color: red; }' )
117117 // import with scoped
118- var id = '_v-' + hash ( require . resolve ( './fixtures/import-scoped.css ' ) )
118+ var id = '_v-' + hash ( require . resolve ( './fixtures/import.vue ' ) )
119119 expect ( styles [ 1 ] . textContent ) . to . contain ( 'h1[' + id + '] { color: green; }' )
120120 done ( )
121121 } )
You can’t perform that action at this time.
0 commit comments