5
5
var loaderUtils = require ( "loader-utils" ) ;
6
6
var processCss = require ( "./processCss" ) ;
7
7
var getImportPrefix = require ( "./getImportPrefix" ) ;
8
+ var compileExports = require ( "./compile-exports" ) ;
8
9
9
10
10
11
module . exports = function ( content ) {
11
12
if ( this . cacheable ) this . cacheable ( ) ;
12
13
var callback = this . async ( ) ;
13
14
var query = loaderUtils . parseQuery ( this . query ) ;
14
15
var moduleMode = query . modules || query . module ;
16
+ var camelCaseKeys = query . camelCase || query . camelcase ;
15
17
16
18
processCss ( content , null , {
17
19
mode : moduleMode ? "local" : "global" ,
@@ -33,16 +35,12 @@ module.exports = function(content) {
33
35
"[" + JSON . stringify ( importItem . export ) + "] + \"" ;
34
36
}
35
37
36
- var exportJs = "" ;
37
- if ( Object . keys ( result . exports ) . length > 0 ) {
38
- exportJs = Object . keys ( result . exports ) . map ( function ( key ) {
39
- var valueAsString = JSON . stringify ( result . exports [ key ] ) ;
40
- valueAsString = valueAsString . replace ( result . importItemRegExpG , importItemMatcher . bind ( this ) ) ;
41
- return "\t" + JSON . stringify ( key ) + ": " + valueAsString ;
42
- } . bind ( this ) ) . join ( ",\n" ) ;
43
- exportJs = "module.exports = {\n" + exportJs + "\n};" ;
38
+ var exportJs = compileExports ( result , importItemMatcher . bind ( this ) , camelCaseKeys ) ;
39
+ if ( exportJs ) {
40
+ exportJs = "module.exports = " + exportJs ;
44
41
}
45
42
43
+
46
44
callback ( null , exportJs ) ;
47
45
} . bind ( this ) ) ;
48
46
} ;
0 commit comments