Skip to content

Commit

Permalink
refactor: code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed May 24, 2021
1 parent ae24e69 commit 9c2aaf7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit 9c2aaf7

Please sign in to comment.