File tree 1 file changed +25
-7
lines changed
1 file changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -30,18 +30,21 @@ var addId = postcss.plugin('add-id', function () {
30
30
}
31
31
} )
32
32
33
- module . exports = function ( css ) {
33
+ module . exports = function ( css , map ) {
34
34
this . cacheable ( )
35
35
var cb = this . async ( )
36
36
37
37
var query = loaderUtils . parseQuery ( this . query )
38
38
var options = this . options . vue || { }
39
39
var autoprefixOptions = options . autoprefixer
40
+ var plugins = [ ]
40
41
41
- var processors = [ ]
42
+ // scoped css
42
43
if ( query . scoped ) {
43
- processors . push ( addId )
44
+ plugins . push ( addId )
44
45
}
46
+
47
+ // autoprefixer
45
48
if ( autoprefixOptions !== false ) {
46
49
autoprefixOptions = assign (
47
50
{ } ,
@@ -50,14 +53,29 @@ module.exports = function (css) {
50
53
autoprefixOptions
51
54
)
52
55
var autoprefixer = require ( 'autoprefixer' ) ( autoprefixOptions )
53
- processors . push ( autoprefixer )
56
+ plugins . push ( autoprefixer )
57
+ }
58
+
59
+ // postcss options, for source maps
60
+ var file = loaderUtils . getRemainingRequest ( this )
61
+ var opts
62
+ opts = {
63
+ from : file ,
64
+ to : file ,
65
+ map : {
66
+ inline : false ,
67
+ annotation : false
68
+ }
69
+ }
70
+ if ( map ) {
71
+ opts . map . prev = map
54
72
}
55
73
56
74
currentId = '_v-' + hash ( this . resourcePath )
57
- postcss ( processors )
58
- . process ( css )
75
+ postcss ( plugins )
76
+ . process ( css , opts )
59
77
. then ( function ( result ) {
60
- cb ( null , result )
78
+ cb ( null , result . css , result . map )
61
79
} )
62
80
. catch ( function ( e ) {
63
81
console . log ( e )
You can’t perform that action at this time.
0 commit comments