File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,11 @@ module.exports = function (content) {
38
38
defaultLoaders . js = 'babel-loader'
39
39
}
40
40
41
+ // enable css source map if needed
42
+ if ( this . sourceMap ) {
43
+ defaultLoaders . css = 'style-loader!css-loader?sourceMap'
44
+ }
45
+
41
46
// check if there are custom loaders specified via
42
47
// webpack config, otherwise use defaults
43
48
var loaders = assign ( { } , defaultLoaders , options . loaders )
@@ -92,12 +97,12 @@ module.exports = function (content) {
92
97
}
93
98
return injectString + ensureBang ( loader )
94
99
} else {
95
- // unknown lang, assume a loader for it is used
100
+ // unknown lang, infer the loader to be used
96
101
switch ( type ) {
97
102
case 'template' :
98
- return 'vue- html!' + rewriter + 'template-html?raw&engine=' + lang + '!'
103
+ return defaultLoaders . html + ' !' + rewriter + 'template-html-loader ?raw&engine=' + lang + '!'
99
104
case 'style' :
100
- return 'style! css!' + rewriter + lang + '!'
105
+ return defaultLoaders . css + ' !' + rewriter + lang + '!'
101
106
case 'script' :
102
107
return injectString + lang + '!'
103
108
}
Original file line number Diff line number Diff line change @@ -67,23 +67,25 @@ module.exports = function (css, map) {
67
67
opts = {
68
68
from : file ,
69
69
to : file ,
70
- map : {
70
+ map : this . sourceMap && {
71
71
inline : false ,
72
72
annotation : false
73
73
}
74
74
}
75
- if ( map ) {
75
+ if ( map && opts . map ) {
76
76
opts . map . prev = map
77
77
}
78
78
79
79
currentId = query . id
80
80
postcss ( plugins )
81
81
. process ( css , opts )
82
82
. then ( function ( result ) {
83
- var map = result . map . toJSON ( )
83
+ var map = result . map && result . map . toJSON ( )
84
84
// ensure we give the style source a unique name
85
85
// so that Webpack doesn't get confused
86
- map . sources [ 0 ] = query . file + '.style'
86
+ if ( map ) {
87
+ map . sources [ 0 ] = query . file + '.style'
88
+ }
87
89
cb ( null , result . css , map )
88
90
} )
89
91
. catch ( function ( e ) {
Original file line number Diff line number Diff line change @@ -153,8 +153,9 @@ describe('vue-loader', function () {
153
153
var line
154
154
var col
155
155
var lines = code . split ( / \r ? \n / g)
156
+ var targetRE = / ^ \s + m s g : ' H e l l o f r o m C o m p o n e n t A ! ' /
156
157
lines . some ( function ( l , i ) {
157
- if ( l . indexOf ( 'Hello from Component A' ) > - 1 ) {
158
+ if ( targetRE . test ( l ) ) {
158
159
line = i
159
160
col = lines [ i - 1 ] . length
160
161
return true
You can’t perform that action at this time.
0 commit comments