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')
2
2
var assign = require ( 'object-assign' )
3
3
var selectorPath = require . resolve ( './selector' )
4
4
var parserPath = require . resolve ( './parser' )
5
+ var hash = require ( 'hash-sum' )
5
6
6
7
var defaultLang = {
7
8
template : 'html' ,
@@ -28,6 +29,7 @@ module.exports = function (content) {
28
29
var output = ''
29
30
var options = this . options . vue || { }
30
31
var vueUrl = loaderUtils . getRemainingRequest ( this )
32
+ var moduleId = '_v-' + hash ( this . resourcePath )
31
33
32
34
// respect user babel options
33
35
if ( this . options . babel ) {
@@ -98,9 +100,9 @@ module.exports = function (content) {
98
100
function getRewriter ( type , scoped ) {
99
101
switch ( type ) {
100
102
case 'template' :
101
- return scoped ? ( rewriters . template + '!' ) : ''
103
+ return scoped ? ( rewriters . template + '?id=' + moduleId + ' !') : ''
102
104
case 'style' :
103
- return rewriters . style + ( scoped ? '? scoped=true!' : '!' )
105
+ return rewriters . style + '?id=' + moduleId + ( scoped ? '& scoped=true!' : '!' )
104
106
default :
105
107
return ''
106
108
}
Original file line number Diff line number Diff line change 1
1
var postcss = require ( 'postcss' )
2
2
var selectorParser = require ( 'postcss-selector-parser' )
3
- var hash = require ( 'hash-sum' )
4
3
var loaderUtils = require ( 'loader-utils' )
5
4
var assign = require ( 'object-assign' )
6
5
@@ -71,7 +70,7 @@ module.exports = function (css, map) {
71
70
opts . map . prev = map
72
71
}
73
72
74
- currentId = '_v-' + hash ( this . resourcePath )
73
+ currentId = query . id
75
74
postcss ( plugins )
76
75
. process ( css , opts )
77
76
. then ( function ( result ) {
Original file line number Diff line number Diff line change 1
1
var parse5 = require ( 'parse5' )
2
2
var parser = new parse5 . Parser ( )
3
3
var serializer = new parse5 . Serializer ( )
4
- var hash = require ( 'hash-sum ' )
4
+ var loaderUtils = require ( 'loader-utils ' )
5
5
6
6
module . exports = function ( html ) {
7
7
this . cacheable ( )
8
- var id = '_v-' + hash ( this . resourcePath )
8
+ var query = loaderUtils . parseQuery ( this . query )
9
+ var id = query . id
9
10
var tree = parser . parseFragment ( html )
10
11
walk ( tree , function ( node ) {
11
12
if ( node . attrs ) {
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ describe('vue-loader', function () {
115
115
var styles = window . document . querySelectorAll ( 'style' )
116
116
expect ( styles [ 0 ] . textContent ) . to . contain ( 'h1 { color: red; }' )
117
117
// import with scoped
118
- var id = '_v-' + hash ( require . resolve ( './fixtures/import-scoped.css ' ) )
118
+ var id = '_v-' + hash ( require . resolve ( './fixtures/import.vue ' ) )
119
119
expect ( styles [ 1 ] . textContent ) . to . contain ( 'h1[' + id + '] { color: green; }' )
120
120
done ( )
121
121
} )
You can’t perform that action at this time.
0 commit comments