Skip to content

Commit

Permalink
Merge pull request #997 from aaronreed708/fix-chroma-problem
Browse files Browse the repository at this point in the history
#983: exclude cjs from build
  • Loading branch information
aaronreed708 authored Aug 14, 2024
2 parents 75b8f58 + 8c2f619 commit 0a1666d
Show file tree
Hide file tree
Showing 3 changed files with 1,968 additions and 221 deletions.
27 changes: 27 additions & 0 deletions code/src/ui/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
webpack: {
configure: (config) => {
// ...
const fileLoaderRule = getFileLoaderRule(config.module.rules);
if(!fileLoaderRule) {
throw new Error("File loader not found");
}
fileLoaderRule.exclude.push(/\.cjs$/);
// ...
return config;
}
}
};

function getFileLoaderRule(rules) {
for(const rule of rules) {
if("oneOf" in rule) {
const found = getFileLoaderRule(rule.oneOf);
if(found) {
return found;
}
} else if(rule.test === undefined && rule.type === 'asset/resource') {
return rule;
}
}
}
Loading

0 comments on commit 0a1666d

Please sign in to comment.