11/**
22 * @see https://webpack.github.io/docs/loaders.html
33 */
4- module . exports = function ( script ) {
5- var content = this . exec ( script , __filename ) ;
6- if ( ! content || content . length !== 1 ) {
7- throw new Error ( 'The css-with-mapping-loader must be chained after the css-loader\n' + content ) ;
8- }
4+ module . exports = function ( ) { } ;
5+
6+ /**
7+ * @see https://webpack.github.io/docs/loaders.html#pitching-loader
8+ */
9+ module . exports . pitch = function ( remainingRequest ) {
10+ this . cacheable && this . cacheable ( ) ;
11+
12+ var loaderUtils = require ( 'loader-utils' ) ;
13+ return encode . toString ( ) + '\n' +
14+ 'var result = require(' + loaderUtils . stringifyRequest ( this , "!!" + remainingRequest ) + ');\n' +
15+ 'if (typeof result === "string") {\n' +
16+ 'module.exports = result;\n' +
17+ '} else {\n' +
18+ 'module.exports = encode(result);\n' +
19+ '}\n' ;
20+ } ;
21+
22+ function encode ( content ) {
923 var cssObject = content [ 0 ] ;
1024 var cssContent = cssObject [ 1 ] || '' ;
1125 var cssMapping = cssObject [ 3 ] ;
@@ -17,5 +31,5 @@ module.exports = function (script) {
1731 var sourceURLs = cssMapping . sources . map ( function ( source ) {
1832 return '/*# sourceURL=' + cssMapping . sourceRoot + source + ' */'
1933 } ) ;
20- return 'module.exports = ' + JSON . stringify ( [ cssContent ] . concat ( sourceURLs ) . concat ( [ sourceMapping ] ) . join ( '\n' ) ) ;
21- } ;
34+ return [ cssContent ] . concat ( sourceURLs ) . concat ( [ sourceMapping ] ) . join ( '\n' ) ;
35+ }
0 commit comments