From 8b584bd899d4adec9e7de783fe405e0a32171519 Mon Sep 17 00:00:00 2001 From: foxxyz Date: Tue, 2 Mar 2021 23:49:50 -0800 Subject: [PATCH] fix: also support passed ES modules from `css-loader` in addition to CommonJS format (#47) --- 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;'