Skip to content

Commit 9c2aaf7

Browse files
committedMay 24, 2021
refactor: code
1 parent ae24e69 commit 9c2aaf7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
 

‎src/index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ export default async function loader(content, map, meta) {
111111
const icssPluginImports = [];
112112
const icssPluginApi = [];
113113

114-
if (shouldUseIcssPlugin(options)) {
114+
const needToUseIcssPlugin = shouldUseIcssPlugin(options);
115+
116+
if (needToUseIcssPlugin) {
115117
const icssResolver = this.getResolve({
116118
conditionNames: ["style"],
117119
extensions: [],
@@ -211,7 +213,12 @@ export default async function loader(content, map, meta) {
211213

212214
const importCode = getImportCode(imports, options);
213215
const moduleCode = getModuleCode(result, api, replacements, options, this);
214-
const exportCode = getExportCode(exports, replacements, options);
216+
const exportCode = getExportCode(
217+
exports,
218+
replacements,
219+
needToUseIcssPlugin,
220+
options
221+
);
215222

216223
callback(null, `${importCode}${moduleCode}${exportCode}`);
217224
}

‎src/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,10 @@ function dashesCamelCase(str) {
770770
);
771771
}
772772

773-
function getExportCode(exports, replacements, options) {
773+
function getExportCode(exports, replacements, needToUseIcssPlugin, options) {
774774
let code = "// Exports\n";
775775

776-
if (!shouldUseIcssPlugin(options)) {
776+
if (!needToUseIcssPlugin) {
777777
code += `${
778778
options.esModule ? "export default" : "module.exports ="
779779
} ___CSS_LOADER_EXPORT___;\n`;

0 commit comments

Comments
 (0)