diff --git a/src/postcss-loader.js b/src/postcss-loader.js index bbac026..ec98a65 100644 --- a/src/postcss-loader.js +++ b/src/postcss-loader.js @@ -191,29 +191,27 @@ export default { const cssVariableName = identifier('css', true) if (shouldExtract) { - output += `export default ${JSON.stringify(modulesExported[this.id])};` + output += `export default ${JSON.stringify(modulesExported[this.id])};`; extracted = { id: this.id, code: result.css, map: outputMap - } + }; } else { - const module = supportModules ? - JSON.stringify(modulesExported[this.id]) : - cssVariableName + const module = supportModules ? JSON.stringify(modulesExported[this.id]) : cssVariableName; output += `var ${cssVariableName} = ${JSON.stringify(result.css)};\n` + - `export default ${module};\n` + - `export var stylesheet=${JSON.stringify(result.css)};` + `var styleMapping = ${module};\n` + + `export var stylesheet=${JSON.stringify(result.css)};`; } if (!shouldExtract && shouldInject) { output += typeof options.inject === 'function' ? options.inject(cssVariableName, this.id) : '\n' + `import styleInject from '${styleInjectPath}';\n` + - `styleInject(${cssVariableName}${Object.keys(options.inject).length > 0 ? + `export default /*#__PURE__*/(function() {\n styleInject(${cssVariableName}${Object.keys(options.inject).length > 0 ? `,${JSON.stringify(options.inject)}` : '' - });` + });\n return styleMapping;\n})();`; } return {