1
- ' use strict' ;
1
+ " use strict" ;
2
2
3
3
Object . defineProperty ( exports , "__esModule" , {
4
4
value : true
5
5
} ) ;
6
+ exports . default = PostcssVariablesLoader ;
6
7
7
- exports . default = function ( source ) {
8
- var _this = this ;
8
+ var _loaderUtils = _interopRequireDefault ( require ( "loader-utils" ) ) ;
9
9
10
+ var utils = _interopRequireWildcard ( require ( "./utils" ) ) ;
11
+
12
+ function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function _getRequireWildcardCache ( ) { return cache ; } ; return cache ; }
13
+
14
+ function _interopRequireWildcard ( obj ) { if ( obj && obj . __esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } return newObj ; }
15
+
16
+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
17
+
18
+ function PostcssVariablesLoader ( source ) {
10
19
if ( this . cacheable ) {
11
20
this . cacheable ( ) ;
12
21
}
13
22
14
- var options = _loaderUtils2 . default . parseQuery ( this . query ) ;
23
+ var options = _loaderUtils . default . getOptions ( this ) || { } ;
24
+
15
25
var _done = this . async ( ) ;
16
26
17
27
var transformToConfig = options . es5 ? utils . toES5Config : utils . toConfig ;
18
28
19
- var end = function end ( err , result , path , map ) {
29
+ var end = ( err , result , path , map ) => {
20
30
if ( err ) {
21
31
_done ( err ) ;
22
32
}
@@ -30,37 +40,21 @@ exports.default = function (source) {
30
40
return _done ( null , obj , map ) ;
31
41
} ;
32
42
33
- var emitWarnings = function emitWarnings ( result ) {
34
- result . warnings ( ) . forEach ( function ( msg ) {
35
- return _this . emitWarning ( new Error ( msg . toString ( ) ) ) ;
36
- } ) ;
43
+ var emitWarnings = result => {
44
+ result . warnings ( ) . forEach ( msg => this . emitWarning ( new Error ( msg . toString ( ) ) ) ) ;
37
45
return result ;
38
46
} ;
39
47
40
- var onError = function onError ( error ) {
48
+ var onError = error => {
41
49
if ( error . name === 'CssSyntaxError' ) {
42
- _this . emitError ( error . message + error . showSourceCode ( ) ) ;
50
+ this . emitError ( error . message + error . showSourceCode ( ) ) ;
43
51
end ( ) ;
44
52
} else {
45
53
end ( error ) ;
46
54
}
47
55
} ;
48
56
49
- utils . getPostcss ( true ) . process ( source , { from : this . resourcePath } ) . then ( function ( result ) {
50
- return end ( null , result , _this . resourcePath , result . map ) ;
51
- } ) . catch ( onError ) ;
52
- } ;
53
-
54
- var _loaderUtils = require ( 'loader-utils' ) ;
55
-
56
- var _loaderUtils2 = _interopRequireDefault ( _loaderUtils ) ;
57
-
58
- var _utils = require ( './utils' ) ;
59
-
60
- var utils = _interopRequireWildcard ( _utils ) ;
61
-
62
- function _interopRequireWildcard ( obj ) { if ( obj && obj . __esModule ) { return obj ; } else { var newObj = { } ; if ( obj != null ) { for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) newObj [ key ] = obj [ key ] ; } } newObj . default = obj ; return newObj ; } }
63
-
64
- function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
65
-
66
- module . exports = exports [ 'default' ] ;
57
+ utils . getPostcss ( true ) . process ( source , {
58
+ from : this . resourcePath
59
+ } ) . then ( result => end ( null , result , this . resourcePath , result . map ) ) . catch ( onError ) ;
60
+ }
0 commit comments