Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(worker): prod and dist compat (#53)
- Loading branch information
1 parent
de8063b
commit b4f1e59
Showing
6 changed files
with
79 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
const path = require("path"); | ||
const glob = require("glob"); | ||
|
||
module.exports = | ||
/** @param {import("webpack").Configuration} config */ function (config) { | ||
if (config.resolve) { | ||
config.resolve.alias["@common"] = config.resolve.alias["common"]; | ||
} | ||
|
||
const workers = glob | ||
.sync("./src/main/**/*.worker.ts") | ||
.map((filePath) => { | ||
const name = path.basename(filePath, path.extname(filePath)); | ||
return [ | ||
name, | ||
path.dirname(filePath).split("src/main/")[1], | ||
filePath, | ||
]; | ||
}) | ||
.reduce((acc, [name, directoryPath, filePath]) => { | ||
acc[path.join(directoryPath, name)] = filePath; | ||
return acc; | ||
}, {}); | ||
|
||
if (config.entry) { | ||
config.entry = { | ||
...config.entry, | ||
...workers, | ||
}; | ||
} | ||
|
||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters