From e6167453e140531c04624ba323463b2fff80dca1 Mon Sep 17 00:00:00 2001 From: Quinn Thibeault Date: Wed, 27 Nov 2019 12:15:19 -0700 Subject: [PATCH] Add support for loader chaining In order to chain this loader with another loader like html-loader, the export syntax needs to be removed. Should not break when used as only loader. --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index e2e6621..2479070 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,10 @@ Author Brad Benvenuti @bradbenvenuti */ module.exports = function(content) { + var regex = /(module\.exports\s?=\s?|exports\.default\s?=\s?|export default )"(.*)";?/; + var matches = content.match(regex); + content = (matches && matches[2]) ? matches[2] : content; + this.cacheable && this.cacheable(); this.value = content; return 'module.exports=function(scope){ return `' + content + '`};';