Skip to content

Commit cd8b707

Browse files
author
Zhicheng Wang
committed
bugfix: can't work properly
1 parent 7a2752f commit cd8b707

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "css-with-mapping-loader",
33
"description": "css to string with source mapping loader for webpack",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"main": "./src/css-with-mapping.js",
66
"author": {
77
"name": "Zhicheng Wang",

src/css-with-mapping.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/**
22
* @see https://webpack.github.io/docs/loaders.html
33
*/
4-
module.exports = function (content) {
4+
module.exports = function (script) {
5+
var content = this.exec(script, __filename);
56
if (!content || content.length !== 1) {
6-
throw new Error('The css-with-mapping-loader must be chained after the css-loader');
7+
throw new Error('The css-with-mapping-loader must be chained after the css-loader\n' + content);
78
}
89
var cssObject = content[0];
910
var cssContent = cssObject[1] || '';
@@ -16,5 +17,5 @@ module.exports = function (content) {
1617
var sourceURLs = cssMapping.sources.map(function (source) {
1718
return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
1819
});
19-
return [cssContent].concat(sourceURLs).concat([sourceMapping]).join('\n');
20-
};
20+
return 'module.exports = ' + JSON.stringify([cssContent].concat(sourceURLs).concat([sourceMapping]).join('\n'));
21+
};

0 commit comments

Comments
 (0)