From 19018d0c5e9367b3ccbc8eaef01e1ba213640150 Mon Sep 17 00:00:00 2001 From: foxxyz Date: Mon, 14 Sep 2020 00:34:57 -0700 Subject: [PATCH] fix: also support passed ES modules from `css-loader` in addition to CommonJS format --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 4adcd219..926a498b 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,8 @@ module.exports.pitch = function (remainingRequest) { '', '// load the styles', 'var content = require(' + request + ');', + // get default export if list is an ES Module (CSS Loader v4+) + "if(content.__esModule) content = content.default;", // content list format is [id, css, media, sourceMap] "if(typeof content === 'string') content = [[module.id, content, '']];", 'if(content.locals) module.exports = content.locals;'