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) {
3838 defaultLoaders . js = 'babel-loader'
3939 }
4040
41+ // enable css source map if needed
42+ if ( this . sourceMap ) {
43+ defaultLoaders . css = 'style-loader!css-loader?sourceMap'
44+ }
45+
4146 // check if there are custom loaders specified via
4247 // webpack config, otherwise use defaults
4348 var loaders = assign ( { } , defaultLoaders , options . loaders )
@@ -92,12 +97,12 @@ module.exports = function (content) {
9297 }
9398 return injectString + ensureBang ( loader )
9499 } else {
95- // unknown lang, assume a loader for it is used
100+ // unknown lang, infer the loader to be used
96101 switch ( type ) {
97102 case 'template' :
98- return 'vue- html!' + rewriter + 'template-html?raw&engine=' + lang + '!'
103+ return defaultLoaders . html + ' !' + rewriter + 'template-html-loader ?raw&engine=' + lang + '!'
99104 case 'style' :
100- return 'style! css!' + rewriter + lang + '!'
105+ return defaultLoaders . css + ' !' + rewriter + lang + '!'
101106 case 'script' :
102107 return injectString + lang + '!'
103108 }
Original file line number Diff line number Diff line change @@ -67,23 +67,25 @@ module.exports = function (css, map) {
6767 opts = {
6868 from : file ,
6969 to : file ,
70- map : {
70+ map : this . sourceMap && {
7171 inline : false ,
7272 annotation : false
7373 }
7474 }
75- if ( map ) {
75+ if ( map && opts . map ) {
7676 opts . map . prev = map
7777 }
7878
7979 currentId = query . id
8080 postcss ( plugins )
8181 . process ( css , opts )
8282 . then ( function ( result ) {
83- var map = result . map . toJSON ( )
83+ var map = result . map && result . map . toJSON ( )
8484 // ensure we give the style source a unique name
8585 // 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+ }
8789 cb ( null , result . css , map )
8890 } )
8991 . catch ( function ( e ) {
Original file line number Diff line number Diff line change @@ -153,8 +153,9 @@ describe('vue-loader', function () {
153153 var line
154154 var col
155155 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 ! ' /
156157 lines . some ( function ( l , i ) {
157- if ( l . indexOf ( 'Hello from Component A' ) > - 1 ) {
158+ if ( targetRE . test ( l ) ) {
158159 line = i
159160 col = lines [ i - 1 ] . length
160161 return true
You can’t perform that action at this time.
0 commit comments