From c972c92c6ae5d76e2d13b0a66a870a5569a9beeb Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Mon, 2 Oct 2017 07:04:55 +0200 Subject: [PATCH] fix: escape newline/paragraph separators (#36) Similar to https://github.com/webpack-contrib/json-loader/pull/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. --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index f1c95c6..bd56158 100644 --- a/index.js +++ b/index.js @@ -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; }