Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: code
  • Loading branch information
alexander-akait committed May 24, 2021
commit 9c2aaf76826e4e107e5c97ac6ca72188432243f6
11 changes: 9 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ export default async function loader(content, map, meta) {
const icssPluginImports = [];
const icssPluginApi = [];

if (shouldUseIcssPlugin(options)) {
const needToUseIcssPlugin = shouldUseIcssPlugin(options);

if (needToUseIcssPlugin) {
const icssResolver = this.getResolve({
conditionNames: ["style"],
extensions: [],
Expand Down Expand Up @@ -211,7 +213,12 @@ export default async function loader(content, map, meta) {

const importCode = getImportCode(imports, options);
const moduleCode = getModuleCode(result, api, replacements, options, this);
const exportCode = getExportCode(exports, replacements, options);
const exportCode = getExportCode(
exports,
replacements,
needToUseIcssPlugin,
options
);

callback(null, `${importCode}${moduleCode}${exportCode}`);
}
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,10 +770,10 @@ function dashesCamelCase(str) {
);
}

function getExportCode(exports, replacements, options) {
function getExportCode(exports, replacements, needToUseIcssPlugin, options) {
let code = "// Exports\n";

if (!shouldUseIcssPlugin(options)) {
if (!needToUseIcssPlugin) {
code += `${
options.esModule ? "export default" : "module.exports ="
} ___CSS_LOADER_EXPORT___;\n`;
Expand Down