Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
fix: escape newline/paragraph separators (#36)
Browse files Browse the repository at this point in the history
Similar to webpack-contrib/json-loader#18 the `raw-loader` also needs to properly escape the special unicode characters, as otherwise `webpack` get's highly confused when it sees one of them.
  • Loading branch information
bmeurer authored and joshwiens committed Oct 2, 2017
1 parent 215fba7 commit c972c92
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
module.exports = function(content) {
this.cacheable && this.cacheable();
this.value = content;
return "export default " + JSON.stringify(content);
content = JSON.stringify(content)
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029');
return "export default " + content;
}

0 comments on commit c972c92

Please sign in to comment.