Skip to content

Commit 48ce71d

Browse files
committed
refactor: code
1 parent 6211be7 commit 48ce71d

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

lib/Server.js

+6-16
Original file line numberDiff line numberDiff line change
@@ -1938,25 +1938,15 @@ class Server {
19381938
// _path = "/main" -> outputFilename = "main"
19391939
// _path = "/main.other" -> outputFilename = "main.other"
19401940
const outputFilename = _path.slice(1);
1941-
// main => ["main"]
1942-
// main-other => ["main-other"]
1943-
// main.other => ["main", "other"]
1944-
const splitOutputFilename = outputFilename.split(".");
1941+
19451942
let isOutputModule = false;
19461943

19471944
this.stats.compilation.assetsInfo.forEach((value, key) => {
1948-
// main.js => ["main", "js"]
1949-
// main.another.js => ["main", "another", "js"]
1950-
const splitKey = key.split(".");
1951-
// If key = main.mjs && filename = main => true
1952-
// If key = main-another.mjs && filename = main => false
1953-
// If key = main.other.mjs && filename = main => false
1954-
// If key = main.other.mjs && filename = main.other => true
1955-
if (
1956-
splitKey.length - 1 === splitOutputFilename.length &&
1957-
splitKey[0] === splitOutputFilename[0]
1958-
) {
1959-
extension = path.extname(key);
1945+
const assetExtension = path.extname(key);
1946+
const assetBasename = path.basename(key, assetExtension);
1947+
1948+
if (assetBasename === outputFilename) {
1949+
extension = assetExtension;
19601950
isOutputModule = value.javascriptModule;
19611951
}
19621952
});

0 commit comments

Comments
 (0)